complex command with exec
asked 2015-09-23 17:11:19 +0000
Anonymous
I'm trying to understand why the following command does not work with i3:
bindsym plus exec xrandr --output LVDS1 --brightness "$(xrandr --current --verbose | grep brightness | awk -F: '{if($2>0.9){print(1.0)}else{print($2+0.1)}}')"
My i3 version is latest: 4.10.4
I've also tried
bindsym plus exec "xrandr --output LVDS1 --brightness $(xrandr --current --verbose | grep brightness | awk -F: '{if($2>0.9){print(1.0)}else{print($2+0.1)}}')"
As per @airblader's suggestion, I also extracted the command into a separate script: /home/me/.i3/bi.sh
#!/bin/bash
xrandr --output LVDS1 --brightness $(xrandr --current --verbose | grep brightness | awk -F: '{if($2>0.9){print(1.0)}else{print($2+0.1)}}')
and have the following line in my .i3/config:
bindsym plus exec /home/me/.i3/bi.sh
but no luck still. Can anyone tell me what I'm doing wrong?
a) Does binding another command ("exec i3-nagbar") work for "bindsym plus"? b) Does the script work if you call it from the command line?
I feel stupid but it appears that i3 runs exec in bash -c, where aliases don't work. (I had `alias grep=grep -i`). `exec xrandr --output LVDS1 --brightness $(xrandr --current --verbose | grep Brightness | awk -F: '{if($2>0.9){print(1.0)}else{print($2+0.1)}}')` works fine (brigthness->Brigthness).
Good to hear you figured it out. exec just passes the command to /bin/sh, by the way. :)
ah I see. Well I'm beginning to think that I'm not my brightness is not as much as I used to think..