Alex's log 2013-01-20

Gnome 3 comforts

Epiphany

Set the default search engine to SSL Google:

dconf write /org/gnome/epiphany/keyword-search-url "'https://www.google.com.au/search?q=%s'"

Ensure we can use C-Tab for tab switching (my laptop has no PageUp/Down keys):

dconf write /org/gnome/epiphany/enabled-extensions "['extensions-manager-ui', 'adblock', 'html5tube', 'tab-key-tab-navigate']"

Enable the do not track header:

dconf write /org/gnome/epiphany/web/do-not-track true

Application Hotkeys

We need hotkeys that switch to an application if it’s running and otherwise start it.

We can do this using the nifty wmctrl program. First take note of the window class of the application you’re interested in with the:

$ wmctrl -xl
0x02200006  0 gnome-terminal.Gnome-terminal  localhost Terminal
0x02e00047  0 emacs.Emacs           localhost emacs@localhost

Once we know the window’s class we can activate (focus and raise) it with wmctrl -xa:

wmctrl -xa emacs.Emacs

Finally if the application is not running we need to start it. Handily wmctrl returns a non-zero exit code on not finding the window so a shell logical-or (||) will do the trick:

wmctrl -xa emacs.Emacs || emacs

If you’re using Gnome to set the shortcuts (Control Center - Keyboard - Shortcuts - Custom Shortcuts) you will need to wrap the commmand in a call to a shell:

sh -c 'wmctrl -xa emacs.Emacs || emacs'

Here are my settings:

dconf load /org/gnome/settings-daemon/plugins/media-keys/ <<EOF
[/]
custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/epiphany/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/emacs/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/terminal/']

[custom-keybindings/epiphany]
binding='<Super>w'
command="sh -c 'wmctrl -x -a epiphany.Epiphany || epiphany'"
name='Epiphany'

[custom-keybindings/emacs]
binding='<Super>e'
command="sh -c 'wmctrl -x -a emacs.Emacs || emacs'"
name='Emacs'

[custom-keybindings/terminal]
binding='<Super>d'
command="sh -c 'wmctrl -x -a gnome-terminal.Gnome-terminal || gnome-terminal'"
name='Terminal'
EOF

If we want to use Super as a modifier you’ll find that Gnome Shell hijacks it and gets in the way. We can bind it to S-a instead:

dconf write /org/gnome/mutter/overlay-key "''"
dconf write /org/gnome/desktop/wm/keybindings/panel-main-menu "['<Super>a','<Alt>F1']"
dconf write /org/gnome/desktop/wm/keybindings/panel-run-dialog "['<Super>r','<Alt>F2']"

Comments