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

Ubuntu: Only works in debug mode #19

Closed hotice closed 8 years ago

hotice commented 8 years ago

I've tried ScreenKey 0.8 in Ubuntu 14.04 and 15.10 and in both, the application only works in debug mode. If I simply type "screenkey" in a terminal, there's no output, no Ubuntu AppIndicator and no keys show up on the screen. If I launch it with "screenkey -d" instead, the Ubuntu AppIndicator shows up and the application works.

I'm not sure how to debug it since... it does work in debug mode.

wavexx commented 8 years ago

On 12/11/15 14:10, Andrew wrote:

I've tried ScreenKey 0.8 in Ubuntu 14.04 and 15.10 and in both, the application only works in debug mode. If I simply type "screenkey" in a terminal, there's no output, no Ubuntu AppIndicator and no keys show up on the screen. If I launch it with "screenkey -d" instead, the Ubuntu AppIndicator shows up and the application works.

I'm not sure how to debug it since... it does work in debug mode.

:P

Does it write anything (exceptions, warnings) when you run it in a terminal without debug?

Just empty?

After running it normally, does it show up as a process? Typing:

ps axuw |grep screenkey

on a terminal will tell you.

hotice commented 8 years ago

No, there's absolutely no output when I run it normally. I also tried running "screenkey --show-settings" and it's the same: no output, no settings window displayed.

Yes, the process is there if I run it normally, it just doesn't seem to do anything.

hotice commented 8 years ago

I ran "screenkey" normally, without the debug mode and after a while, it started displaying my keys on the screen and there was also an output now:

Error creating proxy: Error calling StartServiceByName for org.gtk.vfs.Daemon: Timeout was reached (g-io-error-quark, 24)

(screenkey:10087): GVFS-CRITICAL **: fill_mountable_info: assertion 'proxy != NULL' failed

Then I was able to replicate it. It seems it starts working 20 seconds after I run it in normal mode (by working I mean it displays the keys on the screen, but there's still no Ubuntu AppIndicator).

hotice commented 8 years ago

Does ScreenKey use a daemon when running normally? It it does, then it might be related to this issue: https://bugs.launchpad.net/ubuntu/+source/xfce4-settings/+bug/1239014

wavexx commented 8 years ago

On 12/11/15 14:28, Andrew wrote:

Does ScreenKey use a daemon when running normally? It it does, then it might be related to this issue: https://bugs.launchpad.net/ubuntu/+source/xfce4-settings/+bug/1239014

Yes, screenkey by default daemonizes itself. So that could explain why it does work in debug mode.

You can try the --no-detach flag, which makes it run in the foreground instead.

hotice commented 8 years ago

Indeed, "--no-detach" works too. Thanks!

wavexx commented 8 years ago

On 12/11/15 15:32, Andrew wrote:

Indeed, "--no-detach" works too. Thanks!

I'll have to check whether there's a real issue in screenkey or not.

I also noticed that no icon appears in the systray.

hotice commented 8 years ago

Yes, there's no icon when running "screenkey" normally but the icon shows up with "--no-detach". On the other hand, now Screenkey doesn't work at all for me in Ubuntu, it segfaults, I'm not sure what happened.

hotice commented 8 years ago

I found out what was causing the segfault I mentioned earlier: if I enable "fcitx" keyboard input method and I exit the fcitx tray icon, Screenkey segfaults.

wavexx commented 8 years ago

Good to know. I personally tried ibus and regular XIM, maybe there's some gotcha there.

I'm unfortunately short on time this week, but if you have the chance could you try version 0.6.1 and 0.5? (mostly to see if the detach issue is the same).

hotice commented 8 years ago

I've tried both 0.5 and 0.6.1 versions in Ubuntu:

wavexx commented 8 years ago

How deep is your knowledge of fcitx? I tried debugging the input method and it works when used stand-alone, but not with GTK along the way.

hotice commented 8 years ago

Pretty much 0...

wavexx commented 8 years ago

I was able to reduce it to a pretty small test case (https://github.com/fcitx/fcitx/issues/231), of which I'm not still sure it's a GTK or fcitx issue. I'm more keen to think it's some sort of fcitx check, but let's see.

I was also easily able to reproduce the startup issue in ubuntu, but didn't get to it yet.

wavexx commented 8 years ago

On 12/11/15 15:43, Yuri D'Elia wrote:

On 12/11/15 15:32, Andrew wrote:

Indeed, "--no-detach" works too. Thanks!

I'll have to check whether there's a real issue in screenkey or not.

I also noticed that no icon appears in the systray.

Hmm. I don't know if you saw the response, but I was able to actually make fcitx working after installing all the proper fcitx modules (I was missing fcitx-module-x11).

Does it still segfaults for you? (can you try the latest sources to see if you see the error message)?

hotice commented 8 years ago

fcitx-module-x11 is already installed on my system. The latest Screenkey from git still segfaults when exiting the fcitx Ubuntu appindicator/icon. This is all the output that's displayed:

$ screenkey -d
DEBUG:Screenkey:Options loaded.
DEBUG:Screenkey:Restarting LabelManager.
DEBUG:Screenkey:Thread started.
DEBUG:Screenkey:Using AppIndicator.
Segmentation fault
wavexx commented 8 years ago

Did you set XMODIFIERS, GTK_IM_MODULES correctly?

Can you run:

python screenkey-0.8/Screenkey/keylistener.py

directly?

hotice commented 8 years ago

Firstly, a small update: the latest version from git no longer segfaults when exiting the fcitx tray icon. It still doesn't work but this is displayed now (for some reason it was still segfaulting the last time I checked, I'm not sure why):

$ screenkey -d
DEBUG:Screenkey:Options loaded.
DEBUG:Screenkey:Restarting LabelManager.
DEBUG:Screenkey:Thread started.
DEBUG:Screenkey:Using AppIndicator.
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/dist-packages/Screenkey/keylistener.py", line 245, in run
    raise Exception("Cannot initialize input method")
Exception: Cannot initialize input method

Now back to your questions. Firstly, I didn't set or modify anything related to input methods as I don't use any, so everything I have should be the defaults.

As for running keylistener.py directly, it displays basically the same output both when the fcitx tray icon is running and when it's not (so when Screenkey segfaults).

wavexx commented 8 years ago

On 18/11/15 16:06, Andrew wrote:

Firstly, a small update: the latest version from git no longer segfaults when exiting the fcitx tray icon. It still doesn't work but this is displayed now (for some reason it was still segfaulting the last time I checked, I'm not sure why):

Yes, I added an extra check which catches the IM not initializing correctly, which is the cause of further segfaults. It still doesn't work for obvious reasons, but it's probably a sign of misconfiguration somewhere.

To test it, this is what I did:

Note that by default, 15.10 seem to default to ibus.

And it doesn't seem to crash.

env | grep fcitx

shows the relevant:

XMODIFIERS=@im=fcitx GTK_IM_MODULE=fcitx

~/.xinputrc contains:

run_im fcitx

fcitx has too many configuration files to list.

wavexx commented 8 years ago

Meanwhile, I fixed the initialization issue without --no-detach. Now it should work correctly in any case.

hotice commented 8 years ago

I just tested the latest git and indeed, the indicator now works and there's no longer a delay. Thanks!

Regarding the fcitx issue, I really don't know what triggers it. Note that I installed Ubuntu 15.10 back when it was in alpha (there wasn't an actual alpha release but I installed the daily ISO very early in the development) and maybe some package(s) that are no longer in the final release (like packages that aren't available in the repos any more) are still on my system and are causing this. I'm not really sure what I could do to debug it.

Here are my settings:

$ env | grep fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
QT4_IM_MODULE=fcitx
GTK_IM_MODULE=fcitx
$ cat ~/.xinputrc
# im-config(8) generated on Tue, 17 Nov 2015 12:30:05 +0200
run_im fcitx
# im-config signature: 8780a2263fb4f3d1dc88aae72ab3dd32  -
wavexx commented 8 years ago

On 19/11/15 11:34, Andrew wrote:

Regarding the fcitx issue, I really don't know what triggers it. Note that I installed Ubuntu 15.10 back when it was in alpha (there wasn't an actual alpha release but I installed the daily ISO very early in the development) and maybe some package(s) that are no longer in the final release (like packages that aren't available in the repos any more) are still on my system and are causing this. I'm not really sure what I could do to debug it.

If would be nice if you could find that out. I assume other people will be also going to have the same issue.

Maybe different installed packages?

Try to compare the output of dpkg -l | grep fcitx compared to a new system.

As a last record, you could try to save your ~/.config/fcitx directory, then run "im-config" again, which is going to re-generate it anyway. At this point, diff the two.

wavexx commented 8 years ago

I'm closing this. But please re-open if you find out why fcitx doesn't work.

Patola commented 7 years ago

Hi, I am having this problem in Ubuntu 16.04. Tried 0.9-1~webupd8~xenial1 from the webupd8 ppa and also from the latest git. Had this error, also in debug mode and no-detach mode:

[18:23] [8168] [patola@ovo screenkey]% Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/dist-packages/Screenkey/keylistener.py", line 245, in run
    raise Exception("Cannot initialize input method")
Exception: Cannot initialize input method
Patola commented 7 years ago

I don't have fcitx installed. I have installed it to see along with fcitx-module-x11 if it would make any difference and the error was the same. Also tried changing the environment variables as per the other messages here, no luck. Please advise.

wavexx commented 7 years ago

Please check your environment to see how the input method and keyboard layout is configured. Please post the results of:

cat ~/.xinputrc env

Unfortunately, screenkey is susceptible to XIM configuration errors which don't show up in GTK/QT as both have different drivers.

Patola commented 7 years ago
[6:37] [8160] [patola@ovo patola]% cat ~/.xinputrc 
# im-config(8) generated on Fri, 10 Jun 2016 01:02:10 -0300
run_im ibus
# im-config signature: d844c45bc48ca520ae7f6de9dda80841  -
[6:38] [8161] [patola@ovo patola]% env
MBK_VSS=vss
XTERM_VERSION=XTerm(322)
MBK_OUT_PH=ap
LC_NUMERIC=pt_BR.UTF-8
TERM=xterm
GTK2_MODULES=overlay-scrollbar
QT_QPA_PLATFORMTHEME=appmenu-qt5
GPG_AGENT_INFO=/home/patola/.gnupg/S.gpg-agent:0:1
GUAKE_TAB_UUID=0d372810-a84c-40ec-8c7f-50ad82888b96
XDG_SESSION_DESKTOP=ubuntu
SDL_AUDIODRIVER=pulse
PWD=/home/patola
MBK_TARGET_LIB=/usr/cells/sxlib
QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
LC_IDENTIFICATION=pt_BR.UTF-8
SHLVL=3
QT_IM_MODULE=cedilla
LD_LIBRARY_PATH=/usr/lib
GIO_LAUNCHED_DESKTOP_FILE_PID=3769
MBK_SPI_MODEL=/etc/alliance/spimodel.cfg
DERBY_HOME=/usr/lib/jvm/java-8-oracle/db
GNOME_KEYRING_PID=
PERL_LOCAL_LIB_ROOT=/home/patola/perl5:/home/patola/perl5:/home/patola/perl5
XDG_MENU_PREFIX=gnome-
PATH=/home/patola/perl5/bin:/home/patola/.local/share/umake/bin:/home/patola/perl5/bin:/home/patola/perl5/bin:/home/patola/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/bin:/snap/bin:/usr/brlcad/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/patola/bin:/home/patola/bin:/home/patola/bin
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/3249
KONSOLE_DBUS_SESSION=/Sessions/2
SESSION=ubuntu
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_TYPE=x11
XDG_SEAT=seat0
USER=patola
GNOME_KEYRING_CONTROL=
VH_BEHSFX=vbe
LESSOPEN=| /usr/share/source-highlight/src-hilite-lesspipe.sh %s
COLORFGBG=15;0
XTERM_SHELL=/bin/zsh
KONSOLE_PROFILE_NAME=Shell
JAVA_HOME=/usr/lib/jvm/java-8-oracle
KONSOLE_DBUS_SERVICE=:1.79
LC_PAPER=pt_BR.UTF-8
LC_MONETARY=pt_BR.UTF-8
XMODIFIERS=@im=ibus
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-K8c5WVFjS2
MBK_IN_LO=vst
LC_MEASUREMENT=pt_BR.UTF-8
RDS_IN=cif
DREAL_TECHNO_NAME=/etc/alliance/cmos.dreal
MBK_SCALE_X=100
J2SDKDIR=/usr/lib/jvm/java-8-oracle
XTERM_LOCALE=pt_BR.UTF-8
SHELL=/bin/zsh
GTK_IM_MODUKE=cedilla
J2REDIR=/usr/lib/jvm/java-8-oracle/jre
QT_ACCESSIBILITY=1
GENVIEW_TECHNO_NAME=/etc/alliance/cmos.genview
SESSION_MANAGER=local/ovo:@/tmp/.ICE-unix/3520,unix/ovo:/tmp/.ICE-unix/3520
XDG_SESSION_ID=c2
ALLIANCE_TOP=/usr
PERL5LIB=/home/patola/perl5/lib/perl5:/home/patola/perl5/lib/perl5:/home/patola/perl5/lib/perl5
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
PAM_KWALLET5_LOGIN=/tmp/kwallet5_patola.socket
MBK_OUT_LO=vst
COMPIZ_CONFIG_PROFILE=ubuntu
VH_DLYSFX=dly
XDG_VTNR=7
RDS_OUT=cif
DESKTOP_AUTOSTART_ID=1043d52c15fb38db38147756362889053300000035200004
GDMSESSION=ubuntu
LC_ADDRESS=pt_BR.UTF-8
GTK_IM_MODULE=cedilla
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=05;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;40:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
PERL_MM_OPT=INSTALL_BASE=/home/patola/perl5
MBK_WORK_LIB=.
HOME=/home/patola
PAM_KWALLET_LOGIN=/tmp/kwallet_patola.socket
GRAAL_TECHNO_NAME=/etc/alliance/cmos.graal
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
CDPATH=.:/home/patola:/dados
VH_MAXERR=10
XSCH_PARAM_NAME=/etc/alliance/xsch.par
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
INSTANCE=
GIO_LAUNCHED_DESKTOP_FILE=/home/patola/.config/autostart/Yakuake.desktop
LANGUAGE=en_US
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
MBK_CATAL_NAME=CATAL
LC_TIME=pt_BR.UTF-8
WINDOWID=121634852
LANG=en_US.UTF-8
XPAT_PARAM_NAME=/etc/alliance/xpat.par
ELP_TECHNO_NAME=/etc/alliance/prol.elp
LESS= -R 
DISPLAY=:0
MANPATH=:/usr/man:/usr/local/man:/usr/local/share/man:/usr/share/man:/usr/brlcad/share/man
GTK_MODULES=gail:atk-bridge:unity-gtk-module
SAVEHIST=10000
HISTFILE=/home/patola/.zsh_history
VH_PATSFX=pat
MBK_C4_LIB=./cellsC4
LC_TELEPHONE=pt_BR.UTF-8
PROFILEHOME=
MBK_IN_PH=ap
XDG_CURRENT_DESKTOP=Unity
SHELL_SESSION_ID=9ca05da9afee400091e234b68bbac064
MBK_CATA_LIB=.:/usr/cells/sxlib:/usr/cells/dp_sxlib:/usr/cells/rflib:/usr/cells/rf2lib:/usr/cells/ramlib:/usr/cells/romlib:/usr/cells/pxlib:/usr/cells/padlib
LOGNAME=patola
LC_CTYPE=pt_BR.UTF-8
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XFSM_PARAM_NAME=/etc/alliance/xfsm.par
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings
HISTSIZE=10000
XAUTHORITY=/home/patola/.Xauthority
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
MBK_VDD=vdd
DESKTOP_SESSION=ubuntu
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/patola
SESSIONTYPE=gnome-session
GDM_LANG=en_US
LC_NAME=pt_BR.UTF-8
RDS_TECHNO_NAME=/etc/alliance/cmos.rds
JOB=dbus
PERL_MB_OPT=--install_base "/home/patola/perl5"
OLDPWD=/home/patola
_=/usr/bin/env
[6:38] [8162] [patola@ovo patola]% 
wavexx commented 7 years ago

On Fri, Oct 28 2016, Patola wrote:

im-config(8) generated on Fri, 10 Jun 2016 01:02:10 -0300

run_im ibus

So it looks like you're configured for ibus, but can you check if ibus-daemon is also running?

QT_IM_MODULE=cedilla XMODIFIERS=@im=ibus GTK_IM_MODULE=cedilla

This looks broken to me.

First, check if ibus-daemon is running. If you're running ibus, you need to enable XIM support. This is done by running ibus-daemon --xim on the command line, but I have no clue how ubuntu is managing this.

Then, both QT_IM_MODULE and GTK_IM_MODULE are wrong. They should be set to ibus:

export GTK_IM_MODULE=ibus export XMODIFIERS=@im=ibus export QT_IM_MODULE=ibus

I'd suggest to try the following. Open a terminal, kill ibus, then restart it correctly with the correct environment. Then run screenkey:

pkill -9 ibus-daemon export GTK_IM_MODULE=ibus export XMODIFIERS=@im=ibus export QT_IM_MODULE=ibus ibus-daemon -d -x screenkey -d

Patola commented 7 years ago

I have made a bunch of attempts, both changing and not changing environment variables. The problem is that ibus-daemon was not running. If I run it then run screenkey everything works normally.

Those variables might seem weird but that's the way they are supposed to be. Cedilla is a modification of standard ibus mapping to allow ç to be used in place of ć when using the combination ,c.

wavexx commented 7 years ago

On Fri, Oct 28 2016, Patola wrote:

Those variables might seem weird but that's the way they are supposed to be. Cedilla is a modification of standard ibus mapping to allow ç to be used in place of ć when using the combination ,c.

From the docs, I understood cedilla is a normal Xkb mapping, which is why it would work without ibus. It's also strange that you need it, as I would actually configure it by modifying the ibus maps.

But well, I don't have enough knowledge about dbus, so I can be wrong. It's good that it works.