Pages - Menu

Showing posts with label tweaks. Show all posts
Showing posts with label tweaks. Show all posts

Sunday, March 11, 2012

mapping middle-click to a keyboard key under fedora

By far the most popular post on this blog was my old mapping middle-click to a keyboard key trick, which worked well under Ubuntu at the time.

Since then I've switched to Fedora which doesn't package old X11 tools like xkbset. However, this is such a useful thing to have on a laptop I've found a way.

We'll need the xdotool package, so yum install xdotool.

Then under the settings of your Window Manager, simply create a shortcut to xdotool click 2.

Under the default Gnome 3 desktop, this is in the Keyboard page of gnome-control-center.

Under Openbox, we'd add an entry to rc.xml like this
<keybind key="Menu">
  <action name="Execute">
    <command>xdotool click 2</command>
  </action>
</keybind>
And we're done!

xdotool can actually do a whole heap more than just emulate keyboard and mouse events, check out the author's webpage for more info!

Thursday, June 17, 2010

what to do after a fresh ubuntu lucid install

some things are pretty annoying about lucid, specifically the lack of icons in the gnome menu and the stupid window buttons being in a difference place

over at webupd8 there is a handy script which fixes all of this and more. you can follow the instructions there, get the latest version from https://launchpad.net/ubuntustart/+download or just do this in a terminal

sudo apt-get install zenity
wget http://launchpad.net/ubuntustart/0.4.x/0.4.9/+download/ubuntu-10.04-start-0.4.9.7.tar.gz
tar -xvf ubuntu-10.04-start-0.4.9.7.tar.gz
cd ubuntu-10.04-start/
sudo ./ubuntu-10.04-script

i'd suggest not ticking the GetDeb option (last option at the bottom) as this just slowed things down and broke audacious for me

combine this with the excellent Ubuntu Tweak and i have lucid looking and performing exactly how i want

Friday, November 21, 2008

mapping middle-click to a keyboard key

Update 2012: Some of these components have been deprecated and removed from newer distributions. Check this newer post for a different method.

One of the biggest things I miss when using my laptop is the ability to select text in one window, then middle-click paste it into another. Sure, I can push both buttons together, but that requires a degree of accuracy, and it's supposed to be a quick, one-finger action, not a move-two-hands affair. I can imagine this would be infinitely useful using Linux on a Macbook too, as they don't even have right-click. I started looking round for a solution to this problem, and eventually found it.

First, we need install an old accessibility extension to X which is called xkbset. In Ubuntu or Debian, just sudo apt-get install xkbset. The original idea of this software is to provide support for people who might not be able to use a mouse or keyboard so well, so it enables things like MouseKeys (control the cursor with the numpad) and StickyKeys (hit shift, lift off, type a letter, get a capital), and SlowKeys (only register a keypress after a certain amount of time). But we're going to use it to map a keyboard key to a mouse button with MouseKeys.

First, we'll get rid of all the cursor-control stuff, so you can still use your numpad. As root, edit the file /usr/share/X11/xkb/compat/mousekeys and remove everything between interpret.repeat= False; and // New Keysym Actions. Notice this maps some new "keysym" actions below, specifically the one called Pointer_Button2.

Next, we'll make a script to configure xkbset, to turn MouseKeys on, to not turn it off after a period of inactivity, and to map a key of your choice to middle-click. Here's my ~/.middle-click.sh:
#!/bin/bash
# set XKB layout
setxkbmap -layout us
# turn on mousekeys
xkbset m
# stop mousekeys expiring after a timeout
xkbset exp =m
# map keysym to other keysym
xmodmap -e "keysym Menu = Pointer_Button2"
# this also works
# xmodmap -e "keycode 135 = Pointer_Button2"
This maps the Menu key (it's between Right Alt and Right Ctrl on my keyboard, looks like a menu with a mouse cursor) to mouse button 2, which is middle click. Notice I can also use any other key on the keyboard, by commenting out the keysym line, and using the keycode line. Keycodes are different from keyboard to keyboard, so to get the keycode of the key you wish to use, run xev in a terminal, push the key you desire, and watch the terminal output.

For the Mac users, left-click is button 1, and right-click is button 3. If I was using a Mac, I imagine I'd map Right Command to Button2, and Right Option to Button3. I hope the right side of these buttons has a different keycode to the left side. If not, I've read of people using F11 and/or F12. man xmodmap will tell you how to use a modifier like Cmd+F12 if you so desire.

Under Gnome, I use System -> Preferences -> Sessions to start this script as I log in, so I don't have to worry about it again. Don't forget to make your script executable with chmod +x ~/.middle-click.sh

Friday, October 17, 2008

Swappiness

I was reading through the Ubuntu Swap FAQ, and thought I'd make a note on swappiness, which is a configurable value of how much the system should rely on swap space instead of real RAM. Personally, I wish my the computer would never use swap. From the FAQ:
  • swappiness can have a value of between 0 and 100

  • swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible

  • swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache

  • Ubuntu uses a default setting of swappiness=60

To check the swappiness of your system, at a terminal:
cat /proc/sys/vm/swappiness

A temporary change (lost at reboot) can be made with:
sudo sysctl vm.swappiness=10

To make the changes permanent, edit this file:
sudo gedit /etc/sysctl.conf

And edit the value
vm.swappiness=10
(if this value doesn't exist, create it at the end of the file)

Changes will apply at next reboot.