i3: Add microphone management to i3bar
This commit is contained in:
@@ -19,7 +19,8 @@ general {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
order += volume_status
|
order += "volume_status output"
|
||||||
|
order += "volume_status input"
|
||||||
order += spotify
|
order += spotify
|
||||||
order += "wifi"
|
order += "wifi"
|
||||||
order += "external_script presentation_mode"
|
order += "external_script presentation_mode"
|
||||||
@@ -73,7 +74,7 @@ online_status {
|
|||||||
format = " {icon} "
|
format = " {icon} "
|
||||||
}
|
}
|
||||||
|
|
||||||
volume_status {
|
volume_status output {
|
||||||
cache_timeout = 10
|
cache_timeout = 10
|
||||||
format = " {percentage}% "
|
format = " {percentage}% "
|
||||||
format_muted = " mute "
|
format_muted = " mute "
|
||||||
@@ -81,3 +82,13 @@ volume_status {
|
|||||||
command = "pactl"
|
command = "pactl"
|
||||||
color_muted = '#FFFFFF'
|
color_muted = '#FFFFFF'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
volume_status input {
|
||||||
|
cache_timeout = 10
|
||||||
|
format = " active "
|
||||||
|
format_muted = " mute "
|
||||||
|
thresholds = [(0, 'good'), (1, 'bad')]
|
||||||
|
command = "pactl"
|
||||||
|
color_muted = '#FFFFFF'
|
||||||
|
is_input = True
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,10 +3,15 @@
|
|||||||
# name of the sink. execute pactl list sinks to get a list
|
# name of the sink. execute pactl list sinks to get a list
|
||||||
SINKNAME="$(pactl info | grep '^Default Sink:' | cut -d ' ' -f 3-)"
|
SINKNAME="$(pactl info | grep '^Default Sink:' | cut -d ' ' -f 3-)"
|
||||||
|
|
||||||
|
# name of the sink. execute pactl list sinks to get a list
|
||||||
|
SOURCENAME="$(pactl info | grep '^Default Source:' | cut -d ' ' -f 3-)"
|
||||||
|
|
||||||
#SINKNAME="alsa_output.usb-Logitech_Logitech_Wireless_Headset_88C626354D45-00.analog-stereo"
|
#SINKNAME="alsa_output.usb-Logitech_Logitech_Wireless_Headset_88C626354D45-00.analog-stereo"
|
||||||
# this is the worst
|
# this is the worst
|
||||||
SINK=$(( $(pactl list sinks | grep "Name: " | grep -n "${SINKNAME}"$ | grep -o "^[[:digit:]]*") -1))
|
SINK=$(( $(pactl list sinks | grep "Name: " | grep -n "${SINKNAME}"$ | grep -o "^[[:digit:]]*") -1))
|
||||||
|
|
||||||
|
SOURCE=$(( $(pactl list sources | grep "Name: " | grep -n "${SOURCENAME}"$ | grep -o "^[[:digit:]]*") -1))
|
||||||
|
|
||||||
|
|
||||||
getvol() {
|
getvol() {
|
||||||
echo $(pactl list sinks | grep "^[[:space:]]*Volume" | head -n $(( $SINK + 1 )) | tail -n 1 | grep -o "[[:digit:]]*%" | head -n 1 | cut -d "%" -f 1)
|
echo $(pactl list sinks | grep "^[[:space:]]*Volume" | head -n $(( $SINK + 1 )) | tail -n 1 | grep -o "[[:digit:]]*%" | head -n 1 | cut -d "%" -f 1)
|
||||||
@@ -62,6 +67,10 @@ mute-toggle() {
|
|||||||
pactl set-sink-mute $SINKNAME toggle
|
pactl set-sink-mute $SINKNAME toggle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mute-toggle-mic() {
|
||||||
|
pactl set-source-mute $SOURCENAME toggle
|
||||||
|
}
|
||||||
|
|
||||||
status() {
|
status() {
|
||||||
if [[ $(ismuted) == "1" ]] ; then
|
if [[ $(ismuted) == "1" ]] ; then
|
||||||
echo "mute"
|
echo "mute"
|
||||||
@@ -77,8 +86,12 @@ usage() {
|
|||||||
echo "$0 set-vol VOL_PERC"
|
echo "$0 set-vol VOL_PERC"
|
||||||
}
|
}
|
||||||
|
|
||||||
update_status_bar() {
|
update_status_bar_sink() {
|
||||||
~/.i3/scripts/bar-update volume_status
|
~/.i3/scripts/bar-update "volume_status output"
|
||||||
|
}
|
||||||
|
|
||||||
|
update_status_bar_source() {
|
||||||
|
~/.i3/scripts/bar-update "volume_status input"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -95,19 +108,23 @@ case "$1" in
|
|||||||
else
|
else
|
||||||
setvol "$2"
|
setvol "$2"
|
||||||
fi
|
fi
|
||||||
update_status_bar
|
update_status_bar_sink
|
||||||
;;
|
;;
|
||||||
"mute")
|
"mute")
|
||||||
mute
|
mute
|
||||||
update_status_bar
|
update_status_bar_sink
|
||||||
;;
|
;;
|
||||||
"unmute")
|
"unmute")
|
||||||
unmute
|
unmute
|
||||||
update_status_bar
|
update_status_bar_sink
|
||||||
;;
|
;;
|
||||||
"mute-toggle")
|
"mute-toggle")
|
||||||
mute-toggle
|
mute-toggle
|
||||||
update_status_bar
|
update_status_bar_sink
|
||||||
|
;;
|
||||||
|
"mute-toggle-mic")
|
||||||
|
mute-toggle-mic
|
||||||
|
update_status_bar_source
|
||||||
;;
|
;;
|
||||||
"is-muted")
|
"is-muted")
|
||||||
echo $(ismuted)
|
echo $(ismuted)
|
||||||
|
|||||||
Reference in New Issue
Block a user