Browse Source

Add volume script, update i3 volume hotkeys

master
Riyyi 7 years ago
parent
commit
7b68a1d0c6
  1. 18
      .config/i3/blocks
  2. 19
      .config/i3/config
  3. 26
      .config/i3/scripts/brightness.sh
  4. 50
      .config/i3/scripts/volume.sh

18
.config/i3/blocks

@ -30,21 +30,19 @@ markup=none
# Volume indicator # Volume indicator
# #
# The first parameter sets the step (and units to display)
# The second parameter overrides the mixer selection
# See the script for details.
[volume] [volume]
#label=VOL command=$HOME/.config/i3/scripts/volume.sh
#label=♪ markup=pango
label=
instance=Master instance=Master
#instance=PCM interval=once
interval=1 signal=1
signal=10
# Brightness indicator
#
[brightness] [brightness]
command=$HOME/.config/i3/scripts/brightness.sh command=$HOME/.config/i3/scripts/brightness.sh
interval=1 interval=once
signal=2
# Network interface monitoring # Network interface monitoring
# #

19
.config/i3/config

@ -189,14 +189,17 @@ client.urgent $bg-color-urgent $bg-color-urgent $text-color #00FF00
# Keybindings # Keybindings
bindsym $mod+Mod1+l exec $HOME/.config/i3/scripts/lock.sh bindsym $mod+Mod1+l exec $HOME/.config/i3/scripts/lock.sh
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% # Increase sound volume; Pulse Audio # Volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% # Decrease sound volume bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -q -D pulse sset Master 5%+ unmute && pkill -RTMIN+1 i3blocks
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # Mute sound bindsym XF86AudioLowerVolume exec --no-startup-id amixer -q -D pulse sset Master 5%- unmute && pkill -RTMIN+1 i3blocks
bindsym $mod+F3 exec xbacklight -inc 10 # Increase screen brightness bindsym XF86AudioMute exec --no-startup-id amixer -q -D pulse sset Master toggle && pkill -RTMIN+1 i3blocks
bindsym $mod+F2 exec xbacklight -dec 10 # Decrease screen brightness # Screen brightness
bindsym --release Print exec scrot -e "mv \$f $HOME/Pictures/screen_captures/" # Fullscreen screenshot bindsym $mod+F3 exec xbacklight -inc 10 && pkill -RTMIN+2 i3blocks
bindsym --release Shift+Print exec scrot -s -e "mv \$f $HOME/Pictures/screen_captures/" # Selection screenshot bindsym $mod+F2 exec xbacklight -dec 10 && pkill -RTMIN+2 i3blocks
bindsym --release $mod+Print exec scrot -u -e "mv \$f $HOME/Pictures/screen_captures/" # Focused window screenshot # Screenshot
bindsym --release Print exec scrot -e "mv \$f $HOME/Pictures/screen_captures/" # Fullscreen
bindsym --release Shift+Print exec scrot -s -e "mv \$f $HOME/Pictures/screen_captures/" # Selection
bindsym --release $mod+Print exec scrot -u -e "mv \$f $HOME/Pictures/screen_captures/" # Focused window
# Window appearance # Window appearance
smart_gaps on smart_gaps on

26
.config/i3/scripts/brightness.sh

@ -1,24 +1,20 @@
#!/bin/bash #!/bin/bash
case $BLOCK_BUTTON in case $BLOCK_BUTTON in
# right click 3) xbacklight -set 30 ;; # right click
3) xbacklight -set 30;; 4) xbacklight -inc 10 ;; # scroll up
5) xbacklight -dec 10 ;; # scroll down
# scroll up
4) xbacklight -inc 10 ;;
# scroll down
5) xbacklight -dec 10 ;;
esac esac
percentage=$(printf "%.0f" "$(xbacklight)") PERCENTAGE=$(printf "%.0f" "$(xbacklight)")
if (( $percentage >= 75 )); then if (( $PERCENTAGE >= 75 )); then
icon="" ICON=""
elif (( $percentage >= 25 )); then elif (( $PERCENTAGE >= 25 )); then
icon="" ICON=""
else else
icon="" ICON=""
fi fi
echo $icon $percentage% echo $ICON $PERCENTAGE%

50
.config/i3/scripts/volume.sh

@ -0,0 +1,50 @@
#!/bin/bash
# default (ALSA), pulse, jack
MIXER="pulse"
INSTANCE=${BLOCK_INSTANCE:-"Master"}
STEP="5%"
case $BLOCK_BUTTON in
1) pavucontrol ;; # left click, start sound settings
2) amixer -q -D $MIXER sset $INSTANCE 0 unmute ;; # scroll click, set 0
3) amixer -q -D $MIXER sset $INSTANCE toggle ;; # right click, mute/unmute
4) amixer -q -D $MIXER sset $INSTANCE ${STEP}+ unmute ;; # scroll up, increase
5) amixer -q -D $MIXER sset $INSTANCE ${STEP}- unmute ;; # scroll down, decrease
esac
INFO=$(amixer -D $MIXER get $INSTANCE)
volume() {
VOLUME=$(echo $INFO | sed -nr 's/.*\[([0-9]*)%\].*/\1/p' | head -n 1)
}
symbol() {
if [ "$VOLUME" -ge "50" ]; then
SYMBOL=""
elif [ "$VOLUME" -ge "25" ]; then
SYMBOL=""
else
SYMBOL=""
fi
}
setOutput() {
# If sound is not muted
if [ -n "$(echo $INFO | sed -nr 's/(\[on\])/\1/p')" ]; then
COLOR="#FFF"
volume
symbol
VOLUME="$VOLUME%"
else
COLOR="#676E7D"
VOLUME="MUTE"
SYMBOL=""
fi
}
setOutput
echo "<span color='$COLOR'>$SYMBOL</span> $VOLUME"
Loading…
Cancel
Save