i3: polybar launchscript no more executed by `i3bar_command` (now sway boots without crashing), and switched from `amixer` to `pactl` in `dev-ctrl`

master
Meliurwen 2 years ago
parent c275ec857d
commit 3d9edeb883
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 4
      i3/.config/i3/config
  2. 54
      i3/.config/i3/scripts/dev-ctrl

@ -20,9 +20,7 @@ client.background #ffffff
font pango:monospace 8 font pango:monospace 8
# Polybar # Polybar
bar { exec_always --no-startup-id $HOME/.config/polybar/launch.sh
i3bar_command $HOME/.config/polybar/launch.sh
}
default_border pixel 1 default_border pixel 1
default_floating_border normal default_floating_border normal

@ -1,27 +1,26 @@
#!/bin/sh #!/bin/sh
# You can call this script like this: # You can call this script like this:
# $ ./deviceControl.sh audio up # $ ./deviceControl.sh audio up|down|mute
# $ ./deviceControl.sh audio down
# $ ./deviceControl.sh audio mute
# $ ./deviceControl.sh mic mute # $ ./deviceControl.sh mic mute
# $ ./deviceControl.sh brightness up # $ ./deviceControl.sh brightness up|down
# $ ./deviceControl.sh brightness down #
# Dependencies: dunstify brightnessctl pactl
#
# Acknowledgements: # Acknowledgements:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh # https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a # https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
get_volume() { get_volume() {
amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1 pactl get-sink-volume @DEFAULT_SINK@ | head -n 1 | awk '{print substr($5, 1, length($5)-1)}'
} }
is_mute() { is_mute() {
amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null pactl get-sink-mute @DEFAULT_SINK@ | grep yes > /dev/null
} }
is_mic_mute() { is_mic_mute() {
amixer get Capture | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null pactl get-source-mute @DEFAULT_SOURCE@ | grep yes > /dev/null
} }
get_brightness() { get_brightness() {
@ -102,29 +101,27 @@ send_notification() {
dunstify -i $notif_icon -r $replace_id -u normal "$notif_text" dunstify -i $notif_icon -r $replace_id -u normal "$notif_text"
} }
# set the volume on (if it was muted) # Change default sink volume and toggle on/mute
# and then up/down the volume of the 5% # In case of volume change, unmute first
set_audio() { set_audio() {
case $1 in case $1 in
up) up)
amixer -D pulse set Master on > /dev/null pactl set-sink-mute @DEFAULT_SINK@ 0
amixer -D pulse sset Master 5%+ > /dev/null pactl set-sink-volume @DEFAULT_SINK@ +5%
send_notification audio send_notification audio
;; ;;
down) down)
amixer -D pulse set Master on > /dev/null pactl set-sink-mute @DEFAULT_SINK@ 0
amixer -D pulse sset Master 5%- > /dev/null pactl set-sink-volume @DEFAULT_SINK@ -5%
send_notification audio send_notification audio
;; ;;
mute) mute)
# toggle mute pactl set-sink-mute @DEFAULT_SINK@ toggle
amixer -D pulse set Master 1+ toggle > /dev/null
send_notification audio send_notification audio
;; ;;
mic) *)
# toggle microphone mute printf "Unrecognized audio setting!"
amixer -D pulse set Capture toggle > /dev/null exit 1
send_notification mic
;; ;;
esac esac
} }
@ -140,16 +137,23 @@ set_brightness() {
brightnessctl s 5%- brightnessctl s 5%-
send_notification brightness send_notification brightness
;; ;;
*)
printf "Unrecognized brightness setting!"
exit 1
;;
esac esac
} }
set_mic() { set_mic() {
case $1 in case $1 in
mute) mute)
# toggle microphone mute pactl set-source-mute @DEFAULT_SOURCE@ toggle
amixer -D pulse set Capture toggle > /dev/null
send_notification mic send_notification mic
;; ;;
*)
printf "Unrecognized mic setting!"
exit 1
;;
esac esac
} }
@ -163,4 +167,8 @@ case $1 in
mic) mic)
set_mic "$2" set_mic "$2"
;; ;;
*)
printf "Unrecognized argument!"
exit 1
;;
esac esac

Loading…
Cancel
Save