-
Notifications
You must be signed in to change notification settings - Fork 36
Tips and Tricks
Advanced usage patterns and power user tips for i3-volume.
- Configuration Tips
- Workflow Optimization
- Advanced Scripting
- Performance Tips
- Creative Use Cases
- Troubleshooting Tips
Split your configuration into logical files:
# ~/.config/i3-volume/config
source notifications.dunst
source volume-control.conf
source per-sink.conf
source aliases.confThis makes your configuration easier to manage and maintain.
Use the -D option to automatically save your preferred step size:
volume -D 10 up # Saves DEFAULT_STEP=10 to configUse sink nicks (short names) instead of full sink IDs when possible - they're more stable:
# Good - uses nick (more stable)
SINK_MAX_VOL[USB Audio]=150
# Also works but less stable
SINK_MAX_VOL[alsa_output.pci-0000_00_1f.3.analog-stereo]=150Find sink nicks with: volume list sinks
If notification tools aren't in your PATH:
# In your shell config (~/.bashrc, ~/.zshrc, etc.)
export DUNSTIFY_PATH=/usr/local/bin/dunstify
export XOSD_PATH=/opt/xosd/bin/osd_catOr set in config file (if supported) or use full paths in keybindings.
Create aliases or keybindings for frequently used sinks:
# In ~/.config/i3/config
bindsym $mod+F8 exec --no-startup-id ~/i3-volume/volume -n switch
bindsym $mod+Shift+F8 exec --no-startup-id ~/i3-volume/volume -n prev
# Or switch to specific sink
bindsym $mod+F9 exec --no-startup-id ~/i3-volume/volume -n switch "USB Audio"Create profiles for different activities:
# Music production
volume set 60
volume balance 0
volume profile save production
# Gaming
volume set 85
volume balance -5
volume profile save gaming
# Video calls
volume set 50
volume mic set 75
volume profile save video-callSwitch quickly: volume profile gaming
Relative operations are often more convenient:
# Instead of checking current volume and calculating
volume set +10 # Just increase by 10%
# Works with mic and app commands too
volume mic set +5
volume app firefox set -10Use fade option for pleasant volume changes:
# In config
FADE_DURATION=500
# Or per-command
volume -f 1000 up 10 # Smooth 1-second fadeTemporarily boost volume to ensure you hear important notifications:
#!/bin/bash
# important-notify.sh
# Boost volume by 30% for 3 seconds
~/i3-volume/volume boost 30 3
# Send notification
notify-send -u critical "Important" "Check this!"
# Volume automatically restoresNormalize volumes when starting audio applications:
#!/bin/bash
# launch-audio-app.sh
# Launch your app
mpv "$@" &
# Wait a moment for app to start
sleep 1
# Normalize volumes
~/i3-volume/volume normalize apply 75Track volume changes over time:
#!/bin/bash
# volume-logger.sh
# Log volume history to file
~/i3-volume/volume history 50 >> ~/.volume-history.logAdjust volume based on time of day:
#!/bin/bash
# smart-volume.sh
HOUR=$(date +%H)
if [ "$HOUR" -ge 22 ] || [ "$HOUR" -lt 7 ]; then
# Night time - quiet
~/i3-volume/volume profile quiet
elif [ "$HOUR" -ge 7 ] && [ "$HOUR" -lt 9 ]; then
# Morning - moderate
~/i3-volume/volume profile normal
else
# Day time - normal
~/i3-volume/volume profile normal
fiRun with cron: 0 * * * * ~/scripts/smart-volume.sh
Keep all sinks at the same volume automatically:
#!/bin/bash
# auto-sync.sh
# Sync volumes every 30 seconds
while true; do
~/i3-volume/volume sync
sleep 30
doneUse notification grouping (dunst only):
NOTIFICATION_GROUP=trueOr disable notifications for rapid changes:
# Disable notifications, use status bar only
DISPLAY_NOTIFICATIONS=falseUse listen mode instead of polling:
# Good - listens for changes
volume listen "%i %v %p\n"
# Less efficient - polls every interval
# (not recommended)The script automatically caches sink information. If you're having issues, you can invalidate the cache by restarting the script or using volume list sinks to refresh.
Trigger actions based on volume levels:
#!/bin/bash
# volume-monitor.sh
CURRENT_VOL=$(~/i3-volume/volume output json | jq -r '.volume')
if (( $(echo "$CURRENT_VOL > 80" | bc -l) )); then
notify-send "High Volume" "Consider lowering volume to protect hearing"
fiAutomatically lower background apps when starting a new one:
#!/bin/bash
# focus-audio.sh
APP=$1
# Lower all other apps
for app in $(~/i3-volume/volume app list | awk '{print $1}'); do
if [ "$app" != "$APP" ]; then
~/i3-volume/volume app "$app" set 30
fi
done
# Set focus app to normal
~/i3-volume/volume app "$APP" set 80Switch profiles when connecting to different networks:
#!/bin/bash
# network-volume.sh
SSID=$(iwgetid -r)
case "$SSID" in
"Home")
~/i3-volume/volume profile loud
;;
"Office")
~/i3-volume/volume profile quiet
;;
*)
~/i3-volume/volume profile normal
;;
esacLimit volume during certain hours:
#!/bin/bash
# volume-limit.sh
HOUR=$(date +%H)
if [ "$HOUR" -ge 22 ] || [ "$HOUR" -lt 7 ]; then
# Night time - enforce lower max volume
~/i3-volume/volume -x 60 set 50
else
# Day time - normal limits
~/i3-volume/volume -x 100
fiUse dry-run mode to test commands without actually changing volume:
# Test what would happen
volume -d up 10
volume --dry-run set 50
volume -d switch
# See calculated values and constraints
volume -d set -6dB
volume -d -f 1000 up 5This is especially useful when:
- Debugging why a command isn't working
- Testing commands in scripts before running them
- Understanding how volume calculations work
- Verifying sink selection and constraints
Use verbose mode to see what's happening:
volume -v up 5View your current configuration:
volume config showCheck for configuration errors:
volume config validateTest each component separately:
# Test volume control
volume up 5
volume down 5
# Test notifications
volume -n up 5
# Test status bar output
volume output i3blocks
# Test sink switching
volume list sinks
volume switchSee which sink is being used:
# List all sinks
volume list sinks
# Test with specific sink
volume -s "USB Audio" up 5
# Check default sink
wpctl statusUse exit codes to diagnose issues:
volume up 5
echo "Exit code: $?"
# Or use --exit-code for detailed info
volume --exit-codeDon't specify options on every command - use the config file:
# Bad - repetitive
volume -n -N dunst -t i3blocks -u SIGRTMIN+10 up 5
# Good - set in config
DISPLAY_NOTIFICATIONS=true
NOTIFICATION_METHOD="dunst"
STATUSLINE="i3blocks"
SIGNAL="SIGRTMIN+10"
# Then just: volume up 5Configure different settings for different devices:
# Instead of manually adjusting each time
SINK_MAX_VOL[USB Audio]=150
SINK_DEFAULT_STEP[USB Audio]=2Save common configurations as profiles:
volume profile save quiet
volume profile save loudRelative operations are more flexible:
# Good - works from any volume
volume set +10
# Less flexible - need to know current volume
volume set 60 # What if current is 50? Or 70?Combine features for powerful workflows:
# Fade with notifications
volume -n -f 1000 up 10
# Profile with sink switching
volume switch
volume profile gaming- Examples - More practical examples
- Configuration - Configuration reference
- Features - All available features
- Common Issues - Troubleshooting help