2016/07/28

Xmonad: clickable workspaces with azerty layout

Xmonad is a keyboard oriented desktop manager. But sometimes, you still want to do some mouse actions.

Dzen2 provides clickable areas that allows to bind a command to a mouse click on a specific area of a Dzen bar. If you use Dzen2 as your status bar, it is then only a question of mapping the right keystroke to the workspace name and it should work.

The standard configuration to do this is already well documented:

myWorkspaces            = clickable $ ["1","2","3","4","5","6","7","8","9"]
 
  where clickable l     = [ "^ca(1,xdotool key alt+" ++ show (n) ++ ")" ++ ws ++ "^ca()" |
                            (i,ws) <- zip [1..] l,
                            let n = i ]

However I am using an azerty keyboard layout. I am then using a slightly different keyboard layout to switch workspaces. Typing “alt+1”, “alt+2” and so on to switch workspace will then not have any effect for my configuration.

An additional caveat is xdotool which does not honor default keymap unless you explicitly set it beforehand with setxkbmap.

All this taken into account, here is the resulting config snippet that works:

myWorkspaces    = clickable $ ["web","2","3","4","5","6","irc","8","9"]
    where clickable l = [ "^ca(1,setxkbmap fr;xdotool key super+ampersand)web^ca()",
                          "^ca(1,setxkbmap fr;xdotool key super+eacute)2^ca()",
                          "^ca(1,setxkbmap fr;xdotool key super+quotedbl)3^ca()",
                          "^ca(1,setxkbmap fr;xdotool key super+apostrophe)4^ca()",
                          "^ca(1,setxkbmap fr;xdotool key super+parenleft)5^ca()",
                          "^ca(1,setxkbmap fr;xdotool key super+minus)6^ca()",
                          "^ca(1,setxkbmap fr;xdotool key super+egrave)irc^ca()",
                          "^ca(1,setxkbmap fr;xdotool key super+underscore)8^ca()",
                          "^ca(1,setxkbmap fr;xdotool key super+ccedilla)9^ca()"
                        ]

Note that some of my workspaces are named with plain text instead of number. I am also using the super key instead of alt as my Xmonad mod key.

If you are more Haskell fluent than I am, do not hesitate to suggest some factorization.

2013/03/15

Terminal Emulator: Termite

From rxvt-unicode …

Up to a few days ago, I was using rxvt-unicode as my terminal emulator. It works fine, is light (especially with its client/server mode) and integrates nicely with a tilled window manager. But I was needing Fontconfig support which is lacking from rxvt-unicode.

rxvt-unicode

rxvt-unicode

… to LilyTerm …

I first tried to switch to LilyTerm which seems to be appreciated by some people but I was not convinced. The default configuration has some annoying behaviors (confirmation needed when starting the term to launch a specific command, reusing existing window, …) and it has some shortcomings as well (most importantly TERM is set to xterm which is wrong since LilyTerm has 256 colors support).

… to Termite

I have been then suggested to try Termite, a rather recent (first commit is from May 2012), VTE based (as LilyTerm), terminal emulator. The config is really easy and in a few minutes I had a config replicating my rxvt config.

Termite

Termite

Here is my old rxvt config :

URxvt.foreground: white

URxvt*iso14755: False

URxvt.depth: 32
URxvt*background: rgba:0000/0000/0000/cccc
URxvt.loginShell: true
URxvt.perl-lib: /usr/lib/urxvt/perl
URxvt.keysym.M-u: perl:mark-yank-urls:activate_mark_mode
URxvt.underlineURLs: true
URxvt.perl-ext: selection
URxvt.perl-ext-common:  default,matcher
URxvt.matcher.button:   1
URxvt.urlLauncher: /usr/bin/firefox-ux
URxvt.underlineColor: green
URxvt.saveLines: 65535
URxvt.scrollBar: false
URxvt.visualBell: true

URxvt*background:        #333333
URxvt*foreground:        #cccccc
URxvt*cursorColor:       #999999
URxvt*colorBD:           #ffffff
URxvt*colorUL:           #ffff99

!BLK
URxvt*color0:           #666666
URxvt*color8:           #999999
!RED
URxvt*color1:          #CC6699
URxvt*color9:           #FF99CC
!GRN
URxvt*color2:           #99CC66
URxvt*color10:         #CCFF99
!YEL
URxvt*color3:          #CC9966
URxvt*color11:         #FFCC99
!BLU
URxvt*color4:          #6699CC
URxvt*color12:         #99CCFF
!MAG
URxvt*color5:           #9966CC
URxvt*color13:          #CC99FF
!CYN
URxvt*color6:          #66CC99
URxvt*color14:         #99FFCC
!WHT
URxvt*color7:          #CCCCCC
URxvt*color15:         #FFFFFF

URxvt*font:     -ypn-envypn-medium-r-normal--13-130-75-75-c-90-iso8859-1
URxvt*boldFont:     -ypn-envypn-medium-r-normal--13-130-75-75-c-90-iso8859-1

And, here is my Termite config (not exactly the same behavior than rxvt but same look) :

[options]
resize_grip = false
scroll_on_output = false
scroll_on_keystroke = true
audible_bell = false
visible_bell = false
mouse_autohide = false
allow_bold = true
dynamic_title = true
urgent_on_bell = true
clickable_url = true
font = envypn 9
scrollback_lines = 10000
search_wrap = true
#icon_name = terminal
#geometry = 640x480

# 0.0: opaque, 1.0: transparent
transparency = 0.0
pseudo_transparency = false

# "system", "on" or "off"
cursor_blink = system

# "block", "underline" or "ibeam"
cursor_shape = block

# $BROWSER is used by default
browser = firefox

# word characters used for word selection
# (default if unset: all graphic non-punctuation/space characters)
#word_chars = -A-Za-z0-9,./?%&#:_=+@~

[colors]
foreground = #cccccc
foreground_bold = #ffffff
#foreground_dim = #888888
background = #333333
cursor = #999999

# if unset, will reverse foreground and background
#highlight = #2f2f2f

# colors from color0 to color254 can be set
color0 = #666666
color1 = #CC6699
color2 = #99CC66
color3 = #CC9966
color4 = #6699CC
color5 = #9966CC
color6 = #66CC99
color7 = #CCCCCC
color8 = #999999
color9 = #FF99CC
color10 = #CCFF99
color11 = #FFCC99
color12 = #99CCFF
color13 = #CC99FF
color14 = #99FFCC
color15 = #FFFFFF

[hints]
#font = Monospace 12
#foreground = #dcdccc
#background = #3f3f3f
#padding = 2
#border = #3f3f3f
#border_width = 0.5
#roundness = 2.0

# vim: ft=dosini

Moreover, Termite brings some interesting features:

  • Open a new terminal in the current directory: a basic feature I was trying to achieve directly in my Xmonad configuration for months.
  • A command mode which takes its roots into Vim command mode.
  • Scrollback search (really useful when you forgot to pipe a long running command into grep, less or whatever and that you need to find something specific in the output).

Some features are still lacking like settings specifics parameters through CLI arguments and (probably) sending events. These features are needed to use Termite with programs like Cluster SSH. But this is OK as it is something I do not use everyday and I can keep using urxvt for this.

Termite does not have client/server mode either but it is light enough for this not to be a requirement.

If you are looking for a lightweight terminal emulator, I strongly suggest you give Termite a try.

2013/03/15

Edito

I have decided to start a new blog. This new blog has a different scope from my personal blog and thus it does not mean I will not resumeĀ  blogging (my last article is one year old now) there as well.

This blog will be written in English as the content will not be be franco-centric and will be aimed at people with technical background who likely understands English.

Here is a few ideas I have for the first articles:

  • Articles about my desktop environment: which pieces of software I use, some config highlights, …
  • Articles about my HTPC setup: hardware components selection, XBMC setup, …
  • Maybe some articles about monitoring tools (Cacti, Monitorix, …)