I have been test driving the elementary OS Luna beta 1 for the past few weeks and this bug has been bothering me. Essentially, you can’t use the Super key with the scroll wheel to zoom in and out of your desktop. I’ve found this feature to come in handy when sharing my screen with others online. Until the bug is fixed, I’ve found a workaround.
First we’ll need a couple of small packages:
sudo apt-get install xbindkeys xautomation
- xbindkeys is a program that allows you launch shell commands with button combinations from your keyboard/mouse.
- xautomation includes a program called xte which can generate fake keyboard/mouse input to the X server.
- xbindkeys-config is a GUI to help with configuration. I’m a fan of the command line, so we won’t use it here.
We will be setting up two triggers so that when Super + Scroll Wheel happens we call the built-in elementary zoom in/out commands: Super+KP_Add and Super+KP_Subtract respectively.
First, you need to determine what the system name of your Super key is. (I believe xmodmap is installed by default; if not someone can correct me in the comments).
This command will print your modifier map. Mine looks like this:
shift Shift_L (0x32), Shift_R (0x3e) lock Caps_Lock (0x42) control Control_L (0x40), Control_R (0x69), Control_R (0x86) mod1 bracketright (0x23), Alt_L (0x85), Alt_L (0xcc) mod2 Num_Lock (0x4d) mod3 mod4 Super_L (0x25), Super_L (0xce) mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
So my Super key is Mod4. Next I need to determine which buttons my scroll wheel triggers. (Again, I believe this program is installed by default, but if not: sudo apt-get install xev)
This program will launch a small white window and will print out all mouse/keyboard events it receives. Place your mouse in the white window and scroll the mouse wheel up and down. In my case the program printed
ButtonPress event, serial 33, synthetic NO, window 0x3800001, root 0x15c, subw 0x0, time 5180844, (130,106), root:(133,202), state 0x10, button 4, same_screen YES ButtonRelease event, serial 33, synthetic NO, window 0x3800001, root 0x15c, subw 0x0, time 5180845, (130,106), root:(133,202), state 0x810, button 4, same_screen YES ButtonPress event, serial 33, synthetic NO, window 0x3800001, root 0x15c, subw 0x0, time 5181572, (130,106), root:(133,202), state 0x10, button 5, same_screen YES ButtonRelease event, serial 33, synthetic NO, window 0x3800001, root 0x15c, subw 0x0, time 5181573, (130,106), root:(133,202), state 0x1010, button 5, same_screen YES
So we can see that my scroll up is button 4 and scroll down is button 5. Now that we know how the system sees our input we can get to work writing that trigger.
My file contains the following:
#Zoom-In "/usr/bin/xte 'key KP_Add'" Mod4 + b:4 #Zoom-Out "/usr/bin/xte 'key KP_Subtract'" Mod4 + b:5
As per usual, lines that start with a # are ignored by the system.
The third/sixth lines contain the condition that xbindkeys will be looking for. In my case: when Mod4, the Super key, and mouse button 4 or 5 are pressed.
The second/fifth lines declare the respective commands that should be run. Since the Super key will already be pressed down, I only have xte send an Add/Subtract button press.
Now for the fun part: in order for xbindkeys to work, it has to be running
This will run the program in the foreground for testing. Ultimately you’ll want to add it to your start-up applications without the -n.
3 thoughts on “Super + Scroll to Zoom in elementary OS Luna”
thank you so much 🙂 , works great
with my pleasure
It’s very responsive and functional, it was very fast to set up too.
Great solution thanks for sharing!
Quick question; does xev can create security vulnerabilities? keylogging or any other security issues?