Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daemon mode broken for dash #57

Open
tomparkin opened this issue Sep 4, 2024 · 0 comments
Open

Daemon mode broken for dash #57

tomparkin opened this issue Sep 4, 2024 · 0 comments

Comments

@tomparkin
Copy link

On systems where sh is provided by the dash shell (Ubuntu ships like this) the mons daemon mode is broken due to a bashism in the script:

$ checkbashisms mons.sh

possible bashism in mons.sh line 272 ('$(< foo)' should be '$(cat foo)'):
                [ "$(<"$status")" = 'connected' ] && i=$((i+1))

This results in the status file(s) not being read, and hence i always evaluates to 0 each time around the loop. Changes in monitor layout are therefore never detected.

This can be addressed as follows:

diff --git a/mons.sh b/mons.sh
index b86ce5c..f7c5616 100755
--- a/mons.sh
+++ b/mons.sh
@@ -268,8 +268,8 @@ main() {
     if $aFlag ; then
         prev=0; i=0
         while true; do
-            for status in /sys/class/drm/*/status; do
-                [ "$(<"$status")" = 'connected' ] && i=$((i+1))
+            for output_status in /sys/class/drm/*/status; do
+                [ "$(cat "$output_status")" = 'connected' ] && i=$((i+1))
             done
 
             if [ "$i" != "$prev" ]; then

(Note I changed the variable name at the same time since 'status' is a readonly variable in zsh -- while that's not an issue for me it is possible that other people have /bin/sh linked to zsh and they'd then have problems too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant