Comments (7)
Would an on-screen-display built separately for indicating volume and brightness changes be something you would desire as an alternative for having to handle such things via notifications?
I think it would suffice, yes!
Also could you share your script please?
Here's the script:
#!/bin/bash
# Scripts for volume controls for audio and mic
iDIR="$HOME/.config/swaync/icons"
# Get Volume
get_volume() {
volume=$(pamixer --get-volume)
if [[ "$volume" -eq "0" ]]; then
echo "Muted"
else
echo "$volume%"
fi
}
# Get icons
get_icon() {
current=$(get_volume)
if [[ "$current" == "Muted" ]]; then
echo "$iDIR/volume-mute.png"
elif [[ "${current%\%}" -le 30 ]]; then
echo "$iDIR/volume-low.png"
elif [[ "${current%\%}" -le 60 ]]; then
echo "$iDIR/volume-mid.png"
else
echo "$iDIR/volume-high.png"
fi
}
# Notify
notify_user() {
if [[ "$(get_volume)" == "Muted" ]]; then
notify-send -e -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: Muted"
else
notify-send -r 1234 -e -h int:value:"$(get_volume | sed 's/%//')" -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: $(get_volume)"
fi
}
# Increase Volume
inc_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify_user
fi
pamixer -i 5 && notify_user
}
# Decrease Volume
dec_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify_user
fi
pamixer -d 5 && notify_user
}
# Toggle Mute
toggle_mute() {
if [ "$(pamixer --get-mute)" == "false" ]; then
pamixer -m && notify-send -e -u low -i "$iDIR/volume-mute.png" "Volume Switched OFF"
elif [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify-send -e -u low -i "$(get_icon)" "Volume Switched ON"
fi
}
# Toggle Mic
toggle_mic() {
if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
pamixer --default-source -m && notify-send -e -u low -i "$iDIR/microphone-mute.png" "Microphone Switched OFF"
elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
pamixer -u --default-source u && notify-send -e -u low -i "$iDIR/microphone.png" "Microphone Switched ON"
fi
}
# Get Mic Icon
get_mic_icon() {
current=$(pamixer --default-source --get-volume)
if [[ "$current" -eq "0" ]]; then
echo "$iDIR/microphone-mute.png"
else
echo "$iDIR/microphone.png"
fi
}
# Get Microphone Volume
get_mic_volume() {
volume=$(pamixer --default-source --get-volume)
if [[ "$volume" -eq "0" ]]; then
echo "Muted"
else
echo "$volume%"
fi
}
# Notify for Microphone
notify_mic_user() {
volume=$(get_mic_volume)
icon=$(get_mic_icon)
notify-send -e -h int:value:"$volume" -h "string:x-canonical-private-synchronous:volume_notif" -u low -i "$icon" "Mic-Level: $volume"
}
# Increase MIC Volume
inc_mic_volume() {
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
pamixer --default-source -u && notify_mic_user
fi
pamixer --default-source -i 5 && notify_mic_user
}
# Decrease MIC Volume
dec_mic_volume() {
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
pamixer --default-source -u && notify_mic_user
fi
pamixer --default-source -d 5 && notify_mic_user
}
# Execute accordingly
if [[ "$1" == "--get" ]]; then
get_volume
elif [[ "$1" == "--inc" ]]; then
inc_volume
elif [[ "$1" == "--dec" ]]; then
dec_volume
elif [[ "$1" == "--toggle" ]]; then
toggle_mute
elif [[ "$1" == "--toggle-mic" ]]; then
toggle_mic
elif [[ "$1" == "--get-icon" ]]; then
get_icon
elif [[ "$1" == "--get-mic-icon" ]]; then
get_mic_icon
elif [[ "$1" == "--mic-inc" ]]; then
inc_mic_volume
elif [[ "$1" == "--mic-dec" ]]; then
dec_mic_volume
elif [[ "$1" == "--player" ]]; then
# Shitft arguments - expecting player name after --player flag
shift
target_player="$1"
nsink=$(playerctl --list-all | grep -w "${target_player}" | cut -d ":" -f 2)
[ -z "${nsink}" ] && echo "ERROR: Player ${target_player} not active..." && exit 0
# Shitft arguments - expecting action after
shift
action=$1
[ "${action}" == "i" ] && pvl="+" || pvl="-"
playerctl --player="${nsink}" volume 0.0"5""${pvl}"
vol=$(playerctl --player="${nsink}" volume | awk '{ printf "%.0f\n", $0 * 100 }')
notify-send -e -h int:value:"$(echo "$vol" | sed 's/%//')" -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: ${vol}"
else
get_volume
fi
Edit: This script is adapted from some other scripts I've found during the time - any resemblance is not coincidence, but I have lost the sources unfortunately.
Let me know if you need the icons for the notifications.
from ags-top-panel.
Added on-screen-displays to indicate volume and brightness changes.
The settings for this can be configured in Configuration > General
and coloring in Theming > OSD
.
from ags-top-panel.
You can provide an ID in the notify-send command so that all messages originating from the same id won't spam you. To do this you can provide an -r 1234
flag where 1234 is your id.
Example:
notify-send -r 1234 -e -h int:value:"$(get_volume)" -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: $(get_volume)"
from ags-top-panel.
Thanks for your reply.
That does indeed work, but I'm still missing the display of the value hint. This is an example of the exact same notification using swaync
:
And using AGS
notification daemon:
from ags-top-panel.
Would an on-screen-display built separately for indicating volume and brightness changes be something you would desire as an alternative for having to handle such things via notifications?
from ags-top-panel.
Also could you share your script please?
from ags-top-panel.
Great, looking forward to test it out!
from ags-top-panel.
Related Issues (20)
- The underline color for workspaces is unreadable and inconfigurable.
- Media menu card not updating theme change / No option to change media border
- More popover menu theme options HOT 1
- Dynamic theme preset switching using commands HOT 2
- Cava audio visualizer option for media player
- Widget for keyboard layouts HOT 1
- HyprPanel restarts when the Config/Theme import dialog is closed (canceled) HOT 3
- [Feature Request] Better notification management
- Image browse window appers behind bar HOT 1
- ability to include own window titles and media icon without directly changing index.ts for both HOT 1
- any way to fix the dashboard not scaling properly HOT 2
- Change number of shortcuts and directories
- Nix flake broken HOT 6
- Pre Bundled js/css?
- No top bar on Ubuntu 24 HOT 4
- Is it possible to remove buttons background?
- workspace hover bug HOT 1
- Ability to hide bar via hotkey HOT 2
- Bluetooth battery HOT 1
- Cannot change clock icon color
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ags-top-panel.