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
#
# The first parameter sets the step (and units to display)
# The second parameter overrides the mixer selection
# See the script for details.
[volume]
#label=VOL
#label=♪
label=
command=$HOME/.config/i3/scripts/volume.sh
markup=pango
instance=Master
#instance=PCM
interval=1
signal=10
interval=once
signal=1
# Brightness indicator
#
[brightness]
command=$HOME/.config/i3/scripts/brightness.sh
interval=1
interval=once
signal=2
# Network interface monitoring
#

19
.config/i3/config

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

26
.config/i3/scripts/brightness.sh

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