#!/bin/bash | |
# You can call this script like this: | |
# $./volume.sh up | |
# $./volume.sh down | |
# $./volume.sh mute | |
function get_volume { | |
amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1 | |
} | |
function is_mute { | |
amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null | |
} | |
function send_notification { | |
volume=`get_volume` | |
# Make the bar with the special character ─ (it's not dash -) | |
# https://en.wikipedia.org/wiki/Box-drawing_character | |
bar=$(seq -s "─" $(($volume / 5)) | sed 's/[0-9]//g') | |
# Send the notification | |
dunstify -i audio-volume-muted-blocking -t 8 -r 2593 -u normal " $bar" | |
} | |
case $1 in | |
up) | |
# Set the volume on (if it was muted) | |
amixer -D pulse set Master on > /dev/null | |
# Up the volume (+ 5%) | |
amixer -D pulse sset Master 5%+ > /dev/null | |
send_notification | |
;; | |
down) | |
amixer -D pulse set Master on > /dev/null | |
amixer -D pulse sset Master 5%- > /dev/null | |
send_notification | |
;; | |
mute) | |
# Toggle mute | |
amixer -D pulse set Master 1+ toggle > /dev/null | |
if is_mute ; then | |
dunstify -i audio-volume-muted -t 8 -r 2593 -u normal "Mute" | |
else | |
send_notification | |
fi | |
;; | |
esac |
This comment has been minimized.
This comment has been minimized.
Anyway you could do a similar implementation for brightness using |
This comment has been minimized.
This comment has been minimized.
dunstify: command not found |
This comment has been minimized.
This comment has been minimized.
Nice work! But you can improve this via using sh not bash and also you should change the timeout of the notifications because dunstify gets timeout info in milliseconds not seconds. |
This comment has been minimized.
This comment has been minimized.
You should install Dunst |
This comment has been minimized.
This comment has been minimized.
When I use this the notification window itself gets larger/smaller together with the bar, but the example in the gif doesn't. What's happening? |
This comment has been minimized.
This comment has been minimized.
Use |
This comment has been minimized.
This comment has been minimized.
It seems https://github.com/dunst-project/dunst/releases/tag/v1.5.0 For instance, if you installed dunst via apt on Ubuntu 18.04, you will not have it. |
This comment has been minimized.
Hi, I'm very interested in your script, it's actually what I was looking for, but I'm very new to linux and can't figure out how to run it: I'm running lubuntu and I installed dunst following this guide and it works, since notifications are now run by dunst, the problem is that I don't have a usr/share/dunst folder, which as I understand is the default installation folder, so I have no clue where to put the volume.sh file.
Thank you very much