When I put the following line in ~/.xbindkeysrc
GNOME correctly launches application vlc
.
"vlc"
XF86Calculator
The problem is that I'd like to run a shell script. When I put the following in ~/.xbindkeysrc
GNOME doesn't launch my script but calculator.
"/home/menteith/bin/audio.sh"
XF86Calculator
Why is that? The script is executable and works as expected when is run from command line.
UPDATE
Thanks to @PRATAP I know know that when I use a compiled program in ~/.xbindkeysrc
(i.e. not a bash script) and press XF86Calculator
button for the first time it launches my program, but when I press XF86Calculator
button for the second time I launches calculator instead.
UPDATE 2
Thanks to , @Raffa I tried yet another solution. I wrote a simple C program:
#include <stdio.h>
#include <stdlib.h>
int main() {
puts("Starting now:");
system("killall -s1 xbindkeys; /home/menteith/bin/audio");
return 0;
}
It kills xbindkeys
and then runs wrapper, which in turn run the script. However, it still fails to work. After second time and next times calculator
is being launched.
UPDATE 3 My script switched between audio from monitor (HDMI) and audio from PC.
#!/usr/bin/env bash
output=$(pactl list cards |grep 'Active Profile:' | cut -d ':' -f 3)
if [ $output == "analog-stereo" ]; then
out="hdmi-stereo"
else
out="analog-stereo"
fi
echo test
# Set the choosen card profile as sink
pactl set-card-profile "alsa_card.pci-0000_00_1f.3" "output:${out}"
# Set the default sink to the new one
pacmd set-default-sink "alsa_card.pci-0000_00_1f.3.${out}" &> /dev/null
# Redirect the existing inputs to the new sink
for i in $(pacmd list-sink-inputs | grep index | awk '{print $2}'); do
pacmd move-sink-input "$i" "alsa_card.pci-0000_00_1f.3.${out}" &> /dev/null
done
gnome-control-center keyboard
. – menteith Nov 01 '19 at 18:28xbindkeys -v -n
Make sure your shell script is executable (chmod a+x ...
). – meuh Nov 01 '19 at 18:59sh -c /home/user/script.sh
but it is only working for 1 time.. the next time calculator is getting opened.. something wrong.. – PRATAP Nov 01 '19 at 19:05C
program that launches my script and it also works for only 1 time. Curious. – menteith Nov 01 '19 at 21:03