baskerville/sxhkd

Use `sh' as default shell

Closed this issue · 5 comments

I ran into the issue with fish solved by this comment after much trial and error messing around with startup items in my xinitrc.

I tested other shells startup times and fish seems uniquely slow in starting up compared to others (zsh, tcsh, bash, sh).

My suggestion would be to default to `sh' using the SXHKD_SHELL variable, or at the very least warn in the README or somewhere that fish users may experience significant delays in executing commands due to this behaviour

I solved my own problem!

I had an ever growing user path environment variable definition in my config.fish, causing it to traverse the same path n times where n is the amount of times I had instantiated fish since adding that definition.

https://stackoverflow.com/questions/26208231/modifying-path-with-fish-shell#34401308

Would like to suggest reopening this issue to look into using sh/bash by default since I was running into the problem that sxhkd was feeling rather sluggish for me and was fixed by setting the SXHKD_SHELL to point to something more light-weight. I am much happier after the change was made and I imagine I am not the only one that has felt this sluggishness and only serendipitously stumbled upon the solution.

I disagree. sxhkd uses SHELL by default (if SXHKD_SHELL is not in the evironment); that is the user's login shell.

You will only have this "problem" if you have set your login shell to something other than bash and you did not bother reading the 100 lines man page where it is clearly stated what shell sxhkd will use (ergo you have worse problems).

Most sxhkd users don't use bash as their SXHKD_SHELL anyway since bash is not known for its speed; dash is a better option. (I'm not suggesting to force dash as the default; sxhkd should use the shell the user has chosen and not assume a program exists and force that as default.)

Also, most BSD operating systems don't have bash pre-installed.


EXTRA: xkeybinds uses sh by default, but it also only supports sh (and a more sophisticated GNU guile-flavoured scheme configuration format that is pretty cool); while sxhkd, even though naively, let's you use any shell or interpreter to define your hotkeys.

Far point, but I am not advocating for any particular shell be picked necessarily. However, I would imagine that many that use sxhkd use it incidentally as part of bspwm like I do and don't particularly care too much which shell runs many of the commands that you configure it to run. If you do, then you'll easily find the information to change it.

The only reason I am suggesting something like this is that I was dealing with this problem that is essentially invisible and undebuggable as it did not even occur to me that it was the shell that was being used that was causing the sluggishness of sxhkd/bspwm, even though it is obvious in hindsight. I would wager there are then possibly some amount of users using shells that are not optimized at all for being invoked in this way and produce a noticeable delay.

Totally think your points about forcing a default are valid and it would be hard to pick something that works on all target systems, but maybe at least making this significant optimization to the experience being somehow visible to users that may not even realize that they are having a degraded experience?

I would imagine that many that use sxhkd use it incidentally as part of bspwm like I do

If the problem is to let users that have set their login shell to a shell with an high overhead (at least higher than bash's) and have installed sxhkd to use it with bspwm without reading much about sxhkd know about the perfomance issues they will have, I suggest you to ask the authors/maintainers of the installation guide you followed that told you to install sxhkd with bspwm to also mention to install dash and set SXHKD_SHELL to /bin/dash since that is a better choice anyway (using bash for that purpose is still not ideal).


Benchmark comparison between bash, fish, zsh, ksh, and dash on my 10 years old laptop:

bash-5.1$ for shell in bash fish zsh ksh dash; do
> type "$shell" &> /dev/null || continue
> TIMEFORMAT=$shell$'\t%R %U %S'
> time for (( i = 1; i <= 2000; ++i )); do "$shell" -c '/bin/echo hi'; done > /dev/null
> done |& sort -k2,2g | nl
     1  dash    3.787 3.651 0.762
     2  bash    8.083 6.810 1.433
     3  ksh     8.201 7.648 1.091
     4  zsh     8.921 7.398 1.878
     5  fish    17.174 14.273 3.482
copiable snippet of the benchmarking code

for shell in bash fish zsh ksh dash; do
    type "$shell" &> /dev/null || continue
    TIMEFORMAT=$shell$'\t%R %U %S'
    time for (( i = 1; i <= 2000; ++i )); do "$shell" -c '/bin/echo hi'; done > /dev/null
done |& sort -k2,2g | nl