#!/bin/bash
/usr/bin/notify-send 'lol'
#function check_state () {
#toggle_toggle=$(/usr/bin/amixer get Capture | grep -c "\[off\]")
#echo toggle+percent
#toggle_percent=$(/usr/bin/amixer get Capture | grep -c "\[0%\]")
#echo toggle_percent
#let toggle_result=$((toggle_toggle+toggle_percent))
#echo $((toggle_result))
#}
#check_state
#echo $toggle_result # IF 4 = TURNED OFF, IF !=4 TURNED ON
#if [ $((toggle_result)) != 4 ] ; then
# toggle off
# /usr/bin/killall -9 xfce4-notifyd
# /usr/bin/notify-send 'Microphone was left turned on' 'It was automatically disabled.'
# /usr/bin/amixer set Capture toggle
# /usr/bin/amixer set Capture 0
# /usr/bin/amixer set Capture 0%
#fi
exit 0
Service file
[Unit]
Description=Warns if microphone is turned on at startup
After=sound.target
After=display-manager.service
[Service]
ExecStart=/opt/bin/microphone-status
RemainAfterExit=yes
Environment="DISPLAY=:0.0" "XAUTHORITY=/home/tom/.Xauthority"
[Install]
WantedBy=multi-user.target
Note that when i run systemctl start microphone-status.service, it works. On boot up, doesn't. I dont understand the reason
It succeded:
sudo systemctl status microphone-status.service
[sudo] password for tom:
● microphone-status.service - Warns if microphone is turned on at startup
Loaded: loaded (/opt/bin/microphone-status.service; enabled; vendor preset: enabled)
Active: active (exited) since Tue 2020-12-22 20:53:08 CET; 9min ago
Process: 759 ExecStart=/opt/bin/microphone-status (code=exited, status=0/SUCCESS)
Main PID: 759 (code=exited, status=0/SUCCESS)
Dec 22 20:53:08 UNKNOWN-PC systemd[1]: Started Warns if microphone is turned on at startup.
EDIT1:
[Unit]
Description=Turns off microphone at startup
#After=multi-user.target
After=syslog.target
[Service]
Type=simple
ExecStart=/opt/bin/microphone-status
User=tom
RemainAfterExit=yes
Environment="DISPLAY=:0.0" "XAUTHORITY=/home/tom/.Xauthority"
[Install]
WantedBy=multi-user.target
0 Answers