mattydebie/bitwarden-rofi

Freezes entire desktop (i3)

Closed this issue · 18 comments

Hi,

I'd love to switch to this but when I type the hotkey in i3 the entire desktop freezes (Mouse is working but I cannot click anything and only alt+ctrl+f2 is working on the keyboard) .. when I kill rofi-menu waiting for password (I can see the process but I cannot see the question asking to type in my password). After a reboot it works the first time and then next just freezes .. any idea on what it could be ?

Mange commented

Do you have a custom theme for rofi that could fail to load for dmenu mode with the password flag?

Is it possible to start rofi in that configuration at all?
(I would've given you an example command but I'm not near a PC right now.)

I did but tried to disable it. The weird part is that if I start bwmenu from a shell it always works so something must be missing in my environment for i3

Mange commented

Do you get any output if you run your shortcut command manually from a shell?

Does this work for you?

rofi -dmenu -p "Enter something" -password -lines 0

If not, does this work for you?

rofi -dmenu -p "Test" -password -lines 0 -theme /dev/null

both of them works when in a terminal. But when adding them to i3 like

bindsym $mod+Shift+b exec --no-startup-id they hang

Mange commented

Can you show your exact command?

The excact command I was using is:
bindsym $mod+Shift+b exec --no-startup-id /sbin/bwmenu
Tried talking to a co-worker and he is having the same issue as I .. however if I start the normal rofi menu and then launch bwmenu then it does not hang

Mange commented

Does it work when not placed in sbin?

I wonder what would happen if you wrapped the command in a terminal temporarily, because then we could perhaps see some output or at least kill the script using ^C.

For example if you are using gnome-shell you can write it as gnome-terminal -e /sbin/bwmenu.

Just tried with

bindsym $mod+Shift+b exec --no-startup-id alacritty -e /sbin/bwmenu

and that works every time except I do get a temporary terminal. Its like I'm missing something in my i3 environment but no idea on what. Rofi works fine so I'm suspecting its keyctl that somehow needs something although when haning I can see the process of rofi asking for a password but its not displayed

Mange commented

Are you using bash as your default shell? If not, maybe bash is missing some setup. (Note that bwmenu runs in bash)

You could test if i3 is missing something by binding the command env > ~/i3-env, running it, then comparing it to the env of your shell.

diff -u i3-env <(env)
--- i3-env.sorted	2020-03-23 13:51:50.654699219 +0100
+++ zsh-env.sorted	2020-03-23 13:52:04.261497714 +0100
@@ -1,25 +1,59 @@
+ALACRITTY_LOG=/tmp/Alacritty-1282162.log
+BROWSER=brave
+COLORTERM=truecolor
 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
 DESKTOP_SESSION=/usr/share/xsessions/i3
 DISPLAY=:0
+EDITOR=nvim
+FCEDIT=nvim
+FZF_DEFAULT_COMMAND=ag --hidden --ignore .git -f -g ''
+GOPATH=/home/kgn/go
 GTK_MODULES=canberra-gtk-module
+HISTFILE=/home/kgn/.zsh_history
+HISTSIZE=50000
 HOME=/home/kgn
 I3SOCK=/run/user/1000/i3/ipc-socket.1024751
 LANG=en_US.UTF-8
 LC_COLLATE=C
+LC_CTYPE=en_US.UTF-8
 LC_MESSAGES=C
 LC_MONETARY=da_DK.UTF-8
 LC_NUMERIC=C
 LC_TIME=da_DK.UTF-8
+LESS=-Xr
+LESS_TERMCAP_mb=�[01;31m
+LESS_TERMCAP_md=�[01;38;5;74m
+LESS_TERMCAP_me=�[0m
+LESS_TERMCAP_se=�[0m
+LESS_TERMCAP_so=�[38;5;246m
+LESS_TERMCAP_ue=�[0m
+LESS_TERMCAP_us=�[04;38;5;146m
 LOGNAME=kgn
+LSCOLORS=Gxfxcxdxbxegedabagacad
+LS_COLORS=no=00:fi=00:di=36:ln=35:pi=30;44:so=35;44:do=35;44:bd=33;44:cd=37;44:or=05;37;41:mi=05;37;41:ex=01;31:*.cmd=01;31:*.exe=01;31:*.com=01;31:*.bat=01;31:*.reg=01;31:*.app=01;31:*.txt=32:*.org=32:*.md=32:*.mkd=32:*.h=32:*.c=32:*.C=32:*.cc=32:*.cpp=32:*.cxx=32:*.objc=32:*.cl=32:*.sh=32:*.bash=32:*.csh=32:*.zsh=32:*.el=32:*.vim=32:*.java=32:*.pl=32:*.pm=32:*.py=32:*.rb=32:*.hs=32:*.php=32:*.htm=32:*.html=32:*.shtml=32:*.erb=32:*.haml=32:*.xml=32:*.rdf=32:*.css=32:*.sass=32:*.scss=32:*.less=32:*.js=32:*.coffee=32:*.man=32:*.0=32:*.1=32:*.2=32:*.3=32:*.4=32:*.5=32:*.6=32:*.7=32:*.8=32:*.9=32:*.l=32:*.n=32:*.p=32:*.pod=32:*.tex=32:*.go=32:*.sql=32:*.csv=32:*.bmp=33:*.cgm=33:*.dl=33:*.dvi=33:*.emf=33:*.eps=33:*.gif=33:*.jpeg=33:*.jpg=33:*.JPG=33:*.mng=33:*.pbm=33:*.pcx=33:*.pdf=33:*.pgm=33:*.png=33:*.PNG=33:*.ppm=33:*.pps=33:*.ppsx=33:*.ps=33:*.svg=33:*.svgz=33:*.tga=33:*.tif=33:*.tiff=33:*.xbm=33:*.xcf=33:*.xpm=33:*.xwd=33:*.xwd=33:*.yuv=33:*.aac=33:*.au=33:*.flac=33:*.m4a=33:*.mid=33:*.midi=33:*.mka=33:*.mp3=33:*.mpa=33:*.mpeg=33:*.mpg=33:*.ogg=33:*.opus=33:*.ra=33:*.wav=33:*.anx=33:*.asf=33:*.avi=33:*.axv=33:*.flc=33:*.fli=33:*.flv=33:*.gl=33:*.m2v=33:*.m4v=33:*.mkv=33:*.mov=33:*.MOV=33:*.mp4=33:*.mp4v=33:*.mpeg=33:*.mpg=33:*.nuv=33:*.ogm=33:*.ogv=33:*.ogx=33:*.qt=33:*.rm=33:*.rmvb=33:*.swf=33:*.vob=33:*.webm=33:*.wmv=33:*.doc=31:*.docx=31:*.rtf=31:*.odt=31:*.dot=31:*.dotx=31:*.ott=31:*.xls=31:*.xlsx=31:*.ods=31:*.ots=31:*.ppt=31:*.pptx=31:*.odp=31:*.otp=31:*.fla=31:*.psd=31:*.7z=1;35:*.apk=1;35:*.arj=1;35:*.bin=1;35:*.bz=1;35:*.bz2=1;35:*.cab=1;35:*.deb=1;35:*.dmg=1;35:*.gem=1;35:*.gz=1;35:*.iso=1;35:*.jar=1;35:*.msi=1;35:*.rar=1;35:*.rpm=1;35:*.tar=1;35:*.tbz=1;35:*.tbz2=1;35:*.tgz=1;35:*.tx=1;35:*.war=1;35:*.xpi=1;35:*.xz=1;35:*.z=1;35:*.Z=1;35:*.zip=1;35:*.ANSI-30-black=30:*.ANSI-01;30-brblack=01;30:*.ANSI-31-red=31:*.ANSI-01;31-brred=01;31:*.ANSI-32-green=32:*.ANSI-01;32-brgreen=01;32:*.ANSI-33-yellow=33:*.ANSI-01;33-bryellow=01;33:*.ANSI-34-blue=34:*.ANSI-01;34-brblue=01;34:*.ANSI-35-magenta=35:*.ANSI-01;35-brmagenta=01;35:*.ANSI-36-cyan=36:*.ANSI-01;36-brcyan=01;36:*.ANSI-37-white=37:*.ANSI-01;37-brwhite=01;37:*.log=01;34:*~=01;34:*#=01;34:*.bak=01;36:*.BAK=01;36:*.old=01;36:*.OLD=01;36:*.org_archive=01;36:*.off=01;36:*.OFF=01;36:*.dist=01;36:*.DIST=01;36:*.orig=01;36:*.ORIG=01;36:*.swp=01;36:*.swo=01;36:*,v=01;36:*.gpg=34:*.gpg=34:*.pgp=34:*.asc=34:*.3des=34:*.aes=34:*.enc=34:*.sqlite=34:
 MAIL=/var/spool/mail/kgn
 MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
 OLDPWD=/home/kgn
-PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
+PAGER=less -R
+PATH=/home/kgn/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/bin/core_perl:/home/kgn/go/bin:/opt/chefdk/embedded/bin/:/home/kgn/.gem/ruby/2.7.0/bin:/home/kgn/.gem/ruby/2.6.0/bin
 PWD=/home/kgn
+SAVEHIST=10000
 SHELL=/usr/bin/zsh
 SHLVL=1
 SSH_AUTH_SOCK=/run/user/1000/ssh-agent.socket
+TERM=xterm-256color
+TERMINAL=alacritty
 USER=kgn
+VISUAL=nvim
+WINDOWID=20971522
 XAUTHORITY=/home/kgn/.Xauthority
 XDG_CURRENT_DESKTOP=i3
 XDG_RUNTIME_DIR=/run/user/1000

there are a some differences but none that I can say is the one that does it (Btw. I use zsh)

If I run the script with a
set -x
and output to a file I get

++ basename /sbin/bwmenu
+ NAME=bwmenu
+ VERSION=0.4
+ DEFAULT_CLEAR=5
+ BW_HASH=
+ CLEAR=5
+ SHOW_PASSWORD=no
+ AUTO_LOCK=900
+ ITEMS=
+ CLIPBOARD_MODE=
+ ROFI_OPTIONS=()
+ parse_cli_arguments
++ getopt -o c:C --long auto-lock:,clear:,no-clear,show-password,state-path:,help,version --
+ ARGUMENTS=' --'
+ eval set -- ' --'
++ set -- --
+ true
+ case "$1" in
+ shift
+ ROFI_OPTIONS=("$@")
+ break
+ get_session_key
+ '[' 900 -eq 0 ']'
++ keyctl request user bw_session
+ key_id=
++ ask_password
+++ rofi -dmenu -p 'Master Password' -password -lines 0

so I guess its in rofi

Mange commented

What happens if you change the shebang to run in ZSH instead?

Mange commented

Right now the likeliest thing to me is either the PATH change running the wrong Rofi bin or Rofi having this behavior when stdin is empty but isn't closing itself, and this happens for some reason.

yeah tried to switch it to zsh but still no luck .. with strace I can see a poll on fd=0 so its waiting for stdin. Also checked that I only have one rofi binary

Hah I figured out a solution ..
If I change line 25

mpw=$(rofi -dmenu -p "Master Password" -password -lines 0) || exit $?

to

mpw=$(printf ''| rofi -dmenu -p "Master Password" -password -lines 0) || exit $?

when it works perfectly and no longer waits for stdin

Mange commented

Hey, that's great!

Mange commented

See #47 for fix.

fixed in #48