mirror of
https://github.com/kuhyx/scripts.git
synced 2026-07-04 15:23:11 +02:00
feat: add script toggle mic
This commit is contained in:
parent
6265b923b1
commit
556e374236
@ -41,6 +41,9 @@ bindsym XF86AudioLowerVolume exec --no-startup-id /home/kuchy/volume_control.sh
|
|||||||
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
|
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
|
||||||
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
|
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
|
||||||
|
|
||||||
|
# Add a key binding to toggle the microphone
|
||||||
|
bindsym $mod+m exec --no-startup-id /home/kuchy/i3-configuration/scripts/toggle_mic.sh
|
||||||
|
|
||||||
# Use Mouse+$mod to drag floating windows to their wanted position
|
# Use Mouse+$mod to drag floating windows to their wanted position
|
||||||
floating_modifier $mod
|
floating_modifier $mod
|
||||||
|
|
||||||
|
|||||||
48
scripts/toggle_mic.sh
Executable file
48
scripts/toggle_mic.sh
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if amixer is installed, if not, install it
|
||||||
|
if ! command -v amixer &> /dev/null; then
|
||||||
|
echo "amixer could not be found, installing..."
|
||||||
|
sudo pacman -S --noconfirm alsa-utils
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure dbus is running
|
||||||
|
if ! pgrep -x "dbus-daemon" > /dev/null; then
|
||||||
|
echo "Starting dbus..."
|
||||||
|
sudo systemctl start dbus
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure dbus is properly initialized for the user session
|
||||||
|
export $(dbus-launch)
|
||||||
|
|
||||||
|
# Ensure notification-daemon is installed
|
||||||
|
if ! pacman -Qs notification-daemon > /dev/null; then
|
||||||
|
echo "Installing notification-daemon..."
|
||||||
|
sudo pacman -S --noconfirm notification-daemon
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure dunst is installed and running
|
||||||
|
if ! pacman -Qs dunst > /dev/null; then
|
||||||
|
echo "Installing dunst..."
|
||||||
|
sudo pacman -S --noconfirm dunst
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! pgrep -x "dunst" > /dev/null; then
|
||||||
|
echo "Starting dunst..."
|
||||||
|
dunst &
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the current state of the microphone
|
||||||
|
MIC_STATE=$(amixer get Capture | grep '\[on\]')
|
||||||
|
|
||||||
|
if [ -z "$MIC_STATE" ]; then
|
||||||
|
# If the microphone is off, turn it on
|
||||||
|
amixer set Capture cap
|
||||||
|
sleep 1 # Add a delay to ensure notify-send works correctly
|
||||||
|
notify-send "Microphone" "Microphone is now ON"
|
||||||
|
else
|
||||||
|
# If the microphone is on, turn it off
|
||||||
|
amixer set Capture nocap
|
||||||
|
sleep 1 # Add a delay to ensure notify-send works correctly
|
||||||
|
notify-send "Microphone" "Microphone is now OFF"
|
||||||
|
fi
|
||||||
Loading…
Reference in New Issue
Block a user