LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Can't have this script working when launched from acpi event (https://www.linuxquestions.org/questions/linux-general-1/cant-have-this-script-working-when-launched-from-acpi-event-4175644468/)

Tonus 12-17-2018 03:31 PM

Can't have this script working when launched from acpi event
 
Hi, I have a small script to mute sound . It works while launched from root but will fail when launched with acpi event.

Notification appears but sound will not be muted.

Any clue ?


The scipt :

Code:

#!/bin/bash

# get user running pulseaudio
user=$(ps aux | grep /usr/bin/pulse | grep -v grep | awk '{print $1}' | head -1)

# Get device name
device=$(su $user -c 'pactl list sinks' | grep -A1 RUNNING | grep Nom | sed -e s/Nom://g | sed 's/^[ \t]*//;s/[ \t]*$//' | awk -F ": " '{ print $2}')

# what to do
su $user -c 'pactl set-sink-mute '$device' toggle'

# notify action
su $user -c "DISPLAY=:0 /usr/bin/notify-send --expire-time=1000 'VOLUME MUTED' 'toggle'"


BW-userx 12-17-2018 05:03 PM

maybe this might help
https://wiki.archlinux.org/index.php/acpid


All times are GMT -5. The time now is 08:27 PM.