baskerville / sxhkd

Simple X hotkey daemon
BSD 2-Clause "Simplified" License
2.73k stars 140 forks source link

sxhkd in .xprofile: running, but not working #34

Open lc-guy opened 9 years ago

lc-guy commented 9 years ago

Steps to reproduce: 1) In .xprofile: sxhkd & 2) Reboot. 3) Try to use a keystroke: not working. 4) check if sxhkd is running: http://a.pomf.se/cqjuse.png (it does)

Any reason this bug is happening? Something with X, maybe?

anko commented 9 years ago

Are you sure your command is right? You can check if a keystroke has been recognised by binding it to a simple command like echo hi > /tmp/test and checking whether the file /tmp/test was written to.

By the way, you can also run pkill -USR1 -x sxhkd to send a SIGUSR1-signal to sxhkd, to make it reload its configuration file. Then you don't have to reboot to change things.

lc-guy commented 9 years ago

I am sure the command is right: running "pkill sxhkd" and then "sxhkd &" and using the command will work. The reboot wasn't to reload the configuration file, it was to take the .xprofile in account when starting X. You seem to be mistaken: .xprofile is a file read by lightDM and various other login managers when starting the system to know which programs to load after starting X. Putting sxhkd in .xprofile and then rebooting (to restart lightdm and X) will not work, while starting sxhkd manually will work.

jonlorusso commented 9 years ago

3) Try to use a keystroke: not working.

What keystroke/command are you trying? If it's a bspc command, are you sure BSPWM_SOCKET is set?

ghost commented 4 years ago

Same behaviour here. Tried in 2 computers with same results. Oddly sxhkd launched in ~/.xinitrc let only some keystrokes work, but not others. For instance, I've a keystroke that launch my browser when pressed super+dead_grave. If I launch sxhkd by ~/.xinitrc it doesn't launch it, but if I launch sxhkd by putting it inside my bspwmrc it works (launches my browser). But, when in .xinitrc, I can launch a terminal (super+enter), or rofi (super+d), or keepassxc (super+p).

So to summarize, when I start sxhkd by bspwmrc it has no problems, but it has it by xinitrc.

anko commented 4 years ago

@Neules Is there a chance your ~/.xinitrc changes keyboard settings after starting sxhkd (using setxkbmap, xmodmap, etc)? That would cause those symptoms.

ghost commented 4 years ago

Yes It is, but in ~/.xprofile. That's it:

(.xprofile)

xrandr --output $MON1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --rate 144    .00 --output $MON2 --mode 1920x1080 --pos 1920x0 --rotate normal &
picom --experimental-backends --backend glx --config "$HOME/.config/picom/picom.conf" &
unclutter &
#polybar
$PB_DIR/launch.sh &
$HOME/.fehbg &
dunst &
xsetroot -cursor_name left_ptr &
setxkbmap -option caps:escape &
setxkbmap -option altwin:swap_lalt_lwin &
xdotool key --clearmodifiers Num_Lock &

I just launch sxhkd in my bspwmrc now and it works, but I'll want to keep it all tidy in a previous script like ~/.xprofile.

I load ~/.xprofile in my ~/.xinitrc before loading bspwm.

sffjunkie commented 4 years ago

I had come across a similar problem and the solution was to add sxhkd after the setxkbmap and remove the & from the end of the setxkbmap command. When you have the &, sxhkd is started before setxkbmap has finished doing its remapping and everything gets confused.

anasouardini commented 1 year ago

Same problem:

####################
### hotkeydaemon ###
####################
APP_NAME=sxhkd

# Terminate already running bar instances
killall -q $APP_NAME

# Wait until the processes have been shut down
while pgrep -u $UID -x $APP_NAME >/dev/null
do 
    sleep .5
done

# Launch hotkey daemon 
$APP_NAME -c "$HOME/.config/$APP_NAME/i3" "$HOME/.config/$APP_NAME/general" > /dev/null & disown

### WM
exec i3

Weirdly enough, when I redirect the output of sxhkd to a file in home, it magically works:

$APP_NAME -c "$HOME/.config/$APP_NAME/i3" "$HOME/.config/$APP_NAME/general" > ~/looooog & disown

In the "log" file I see "success" messages when I press keybindings.

Also when lunch sxkhd from .profile and then source .profile in .xixnitrc, it works. maybe permissions Issue??

Another weird behavior is, when I put the code that lunches sxdkh in a separate scripts and then execute it from .profile, only some keybindings work :).