View Single Post
Posts: 16 | Thanked: 3 times | Joined on Feb 2008
#28
Ummm, I kinda got this working for a minute. My first problem was that I couldn't get either shell script to work. Playing around on the shell it kept giving me errors about unexpected EOF while looking for 'then'. I'm not very familiar with shell scripting and have never used awk or sed or whatever so I came at it from another direction:

Code:
#!/usr/bin/python
from subprocess import call, Popen, PIPE

xmodmap = Popen(['/usr/bin/xmodmap', '-pp'], stdout=PIPE)
for line in xmodmap.stdout:
  setting = line.split() # get a list of non-whitespace sequences
  if setting: # can't index a zero length list
    print setting
    setting = line.split()[-1] # Get last item in list (button)
		
  if setting == '1':
    print 'click set to lmb, switching'
    #/usr/bin/xmodmap -e "pointer = 3 2 1"
    call(['/usr/bin/xmodmap', '-e', 'pointer = 3 2 1'])
    break
  elif setting == '3':
    print 'click set to rmb, switching'
    #/usr/bin/xmodmap -e "pointer = 1 2 3"
    call(['/usr/bin/xmodmap', '-e', 'pointer = 1 2 3'])
    break
(Written in Kate )

So with the above (and Python) I got right click working. But while playing around it seemed that the RMB mapping would stick more and more. Then everything started slowing down. Then I started getting errors about failed thread creation. Finally the system froze and I had to do a hard reboot...

Looking at it this morning though I think I see where part of the problem came from. With Python I shouldn't need to explicitly close the subprocess, but my problem sure seems like I created a bunch of zombies somewhere. I'll do some more testing today, see if I can add some indication of current button state too.

Is the switch from LMB to RMB slow for people using the shell script? Running my script from the terminal it looks like it only takes a split second. Is the problem with the KDE "input actions" thing?

Last edited by kitsu; 2008-03-07 at 19:27.