wavexx / screenkey

A screencast tool to display your keys inspired by Screenflick
https://www.thregr.org/~wavexx/software/screenkey/
GNU General Public License v3.0
757 stars 66 forks source link

Python 3 support #2

Closed cmoang closed 9 years ago

cmoang commented 9 years ago

I have problems running screenkey. Any ideas?

$ uname -a
Linux screenkeylock 4.0.0-1-mainline #1 SMP PREEMPT Thu Apr 16 18:30:31 WEST 2015 x86_64 GNU/Linux
$ screenkey
Traceback (most recent call last):
  File "/usr/bin/screenkey", line 4, in <module>
    __import__('pkg_resources').run_script('screenkey==0.4', 'screenkey')
  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 729, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1649, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/lib/python3.4/site-packages/screenkey-0.4-py3.4.egg/EGG-INFO/scripts/screenkey",     line 9, in <module>
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/usr/lib/python3.4/site-packages/screenkey-0.4-py3.4.egg/Screenkey/__init__.py", line 2,     in <module>
TypeError: install() got an unexpected keyword argument 'unicode'

$ sudo ./setup.py install
running install
running bdist_egg
running egg_info
writing dependency_links to screenkey.egg-info/dependency_links.txt
writing top-level names to screenkey.egg-info/top_level.txt
writing screenkey.egg-info/PKG-INFO
reading manifest file 'screenkey.egg-info/SOURCES.txt'
writing manifest file 'screenkey.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/Screenkey
copying build/lib/Screenkey/__init__.py -> build/bdist.linux-x86_64/egg/Screenkey
copying build/lib/Screenkey/listenkbd.py -> build/bdist.linux-x86_64/egg/Screenkey
copying build/lib/Screenkey/modmap.py -> build/bdist.linux-x86_64/egg/Screenkey
copying build/lib/Screenkey/screenkey.py -> build/bdist.linux-x86_64/egg/Screenkey
byte-compiling build/bdist.linux-x86_64/egg/Screenkey/__init__.py to __init__.cpython-34.pyc
byte-compiling build/bdist.linux-x86_64/egg/Screenkey/listenkbd.py to listenkbd.cpython-34.pyc
byte-compiling build/bdist.linux-x86_64/egg/Screenkey/modmap.py to modmap.cpython-34.pyc
byte-compiling build/bdist.linux-x86_64/egg/Screenkey/screenkey.py to screenkey.cpython-34.pyc
installing package data to build/bdist.linux-x86_64/egg
running install_data
creating build/bdist.linux-x86_64/egg/share
creating build/bdist.linux-x86_64/egg/share/applications
copying data/screenkey.desktop -> build/bdist.linux-x86_64/egg/share/applications
creating build/bdist.linux-x86_64/egg/share/doc
creating build/bdist.linux-x86_64/egg/share/doc/screenkey
copying README.rst -> build/bdist.linux-x86_64/egg/share/doc/screenkey
copying NEWS.rst -> build/bdist.linux-x86_64/egg/share/doc/screenkey
creating build/bdist.linux-x86_64/egg/EGG-INFO
installing scripts to build/bdist.linux-x86_64/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/bdist.linux-x86_64/egg/EGG-INFO/scripts
copying build/scripts-3.4/screenkey -> build/bdist.linux-x86_64/egg/EGG-INFO/scripts
changing mode of build/bdist.linux-x86_64/egg/EGG-INFO/scripts/screenkey to 755
copying screenkey.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying screenkey.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying screenkey.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying screenkey.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/screenkey-0.4-py3.4.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing screenkey-0.4-py3.4.egg
Removing /usr/lib/python3.4/site-packages/screenkey-0.4-py3.4.egg
Copying screenkey-0.4-py3.4.egg to /usr/lib/python3.4/site-packages
screenkey 0.4 is already the active version in easy-install.pth
Installing screenkey script to /usr/bin

Installed /usr/lib/python3.4/site-packages/screenkey-0.4-py3.4.egg
Processing dependencies for screenkey==0.4
Finished processing dependencies for screenkey==0.4
wavexx commented 9 years ago

On 06/04/2015 06:55 PM, cmoang wrote:

I have problems running screenkey. Any ideas?

Looks like some minor difference in arguments for gettext.install when using python3.

I was able to reproduce it here as well.

I'll fix it in the next few days. You can try with 2.7 meanwhile.

wavexx commented 9 years ago

Unfortunately, xlib or xcb support in python3 is lacking (there are two unofficial ports, both not packaged), so this might actually take time to fix... Python 2.7 is required.

cmoang commented 9 years ago

Sorry to bring this up again. After cloning the project, I still get some errors:

 $ python2 ./screenkey  -p fixed -g $(slop -n -f '%g')
Traceback (most recent call last):
  File "./screenkey", line 98, in <module>
    main()
  File "./screenkey", line 90, in main
    sc.Screenkey(logger=logger, options=options, show_settings=args.show_settings)
  File "/home/screenkey/screenkey/Screenkey/screenkey.py", line 127, in __init__
    self.on_change_mode()
  File "/home/screenkey/screenkey/Screenkey/screenkey.py", line 330, in on_change_mode
    recent_thr=self.options.recent_thr)
  File "/home/screenkey/screenkey/Screenkey/listenkbd.py", line 115, in __init__
    self.keymap = modmap.get_keymap_table()
  File "/home/screenkey/screenkey/Screenkey/modmap.py", line 33, in get_keymap_table
    keymap_table = cmd_keymap_table()
  File "/home/screenkey/screenkey/Screenkey/modmap.py", line 18, in cmd_keymap_table
    'LC_ALL': 'C'})
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
TypeError: execve() arg 3 contains a non-string value

$ python2 --version # on Arch Linux
Python 2.7.10

Any ideas?

wavexx commented 9 years ago

Can you try again with the latest master?

cmoang commented 9 years ago

Wow it works!!!! I am so relieved! Thank you so much! For network stumblers, this:

xmodmap:  unable to open display ':0

doesn't happen after an xhost + ( https://wiki.archlinux.org/index.php/Xhost ).

Last, this is not important for me, but in key combinations with Alt or Ctrl, "Shift" is not captured: Ctrl+Shift+Up is shown correctly as Ctrl+Shift+(up arrow), but Ctrl+Shift+a is shown incorrectly as Ctrl+A. That is, Shift is captured if the third key is a key like Tab, Backspace, PgUp, etc. but not with letters.

wavexx commented 9 years ago

xhost + is probably not what you want. The error was caused by a missing XAUTHORITY, which is normally generated by the X display manger at startup (you probably need xorg-xauth to be installed).

As for shift, it's intended. If there's a letter, "shift" modifies the letter directly to make it capital in order to make the key stream more readable.

But I agree in some situations it might be helpful to make it visible. I will add a note for this.

wavexx commented 9 years ago

FYI, I added issue #4 to keep track of this.