I have the following script to execute "xset led" command on keypress but I cannot make it work for the command does not actually execute. Here is the script:
#!/bin/bash
res=$(echo "$(xset q)" | tr ";" "Scroll Lock")
if [[ $res == *"Scroll Lock: on"* ]]; then
echo $(xset led on)
else
echo $(xset led off)
fi
However when I execute echo $(xset led on) in the shell it works. Executing the script above outputs an empty line, though.