mercredi 1 février 2017

Shell command is not working

I use volnoti, a notification service, together with my i3 window manager, in my i3config file I tried to implement the commands for volnoti like this:

# Pulse Audio controls
# Increase sound volume
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 1 +5% && pkill -RTMIN+1 i3blocks && volnoti-show $(amixer -c 1 -M -D pulse get Master | grep -o '[0-9]*%' -m 1 | grep -o '[0-9]*')
# Decrease sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 1 -5% && pkill -RTMIN+1 i3blocks && volnoti-show $(amixer -c 1 -M -D pulse get Master | grep -o '[0-9]*%' -m 1 | grep -o '[0-9]*')
# Mute sound
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 1 toggle && pkill -RTMIN+1 i3blocks && if [[ -n $(amixer -c 1 -M -D pulse get Master | grep '\[off\]' -m 1) ]]; then volnoti-show -m; else volnoti-show $(amixer -c 1 -M -D pulse get Master | grep -o '[0-9]*%' -m 1 | grep -o '[0-9]*'); fi

Increasing and decreasing is shown without problems, but if I mute the sound i3 logs this error:

ERROR: Could not translate string to key symbol: "split+h"
[libi3] ERROR: Surface 0x555ee0dfd3b0 is not initialized, skipping drawing.
[libi3] ERROR: Surface 0x555ee0dfd3b0 is not initialized, skipping drawing.
[libi3] ERROR: Surface 0x555ee0dfd3b0 is not initialized, skipping drawing.
ERROR: Received ConfigureNotify for unknown window 0x00800000
ERROR: Received ExposeEvent for unknown window 0x00800000
ERROR: Received ConfigureNotify for unknown window 0x00800000
ERROR: Received ConfigureNotify for unknown window 0x00800003
ERROR: Received ConfigureNotify for unknown window 0x00800003
ERROR: Received ConfigureNotify for unknown window 0x00800006
ERROR: Received ConfigureNotify for unknown window 0x00800006
ERROR: Received ConfigureNotify for unknown window 0x00800009
ERROR: Received ConfigureNotify for unknown window 0x00800009
ERROR: Received ConfigureNotify for unknown window 0x0080000c
ERROR: Received ConfigureNotify for unknown window 0x0080000c
ERROR: Expected one of these tokens: <end>, '[', 'move', 'exec', 'exit', 'restart', 'reload', 'shmlog', 'debuglog', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'sticky', 'split', 'floating', 'mark', 'unmark', 'resize', 'rename', 'nop', 'scratchpad', 'title_format', 'mode', 'bar'
ERROR: Your command: exec --no-startup-id pactl set-sink-mute 1 toggle && pkill -RTMIN+1 i3blocks && "if [[ -n $(amixer -c 1 -M -D pulse get Master | grep '\[off\]' -m 1) ]]; then volnoti-show -m; else volnoti-show $(amixer -c 1 -M -D pulse get Master | grep -o '[0-9]*%' -m 1 | grep -o '[0-9]*'); fi"
ERROR:                                                                                                                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I have to admit, it is not the most elegant solution. But it's working, except for the last line. If I execute the last part directly in a terminal, it's working fine and mute is detected properly:

if  [[ -n $(amixer -c 1 -M -D pulse get Master | grep '\[off\]' -m 1) ]]; then volnoti-show -m; else volnoti-show $(amixer -c 1 -M -D pulse get Master | grep -o '[0-9]*%' -m 1 | grep -o '[0-9]*'); fi

Aucun commentaire:

Enregistrer un commentaire