Skip to content
Beau Hastings edited this page Jan 1, 2026 · 2 revisions

Tips & Tricks

Advanced usage patterns and power user tips for i3-volume.

Table of Contents

Configuration Tips

Use Configuration Includes

Split your configuration into logical files:

# ~/.config/i3-volume/config
source notifications.dunst
source volume-control.conf
source per-sink.conf
source aliases.conf

This makes your configuration easier to manage and maintain.

Auto-Save Default Step

Use the -D option to automatically save your preferred step size:

volume -D 10 up  # Saves DEFAULT_STEP=10 to config

Per-Sink Configuration Best Practices

Use 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]=150

Find sink nicks with: volume list sinks

Environment Variables for Custom Paths

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_cat

Or set in config file (if supported) or use full paths in keybindings.

Workflow Optimization

Quick Sink Switching

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"

Volume Profiles for Activities

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-call

Switch quickly: volume profile gaming

Use Relative Operations

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 -10

Fade for Smooth Transitions

Use fade option for pleasant volume changes:

# In config
FADE_DURATION=500

# Or per-command
volume -f 1000 up 10  # Smooth 1-second fade

Advanced Scripting

Volume Boost for Important Notifications

Temporarily 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 restores

Auto-Normalize on Application Launch

Normalize 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 75

Volume History Monitoring

Track volume changes over time:

#!/bin/bash
# volume-logger.sh

# Log volume history to file
~/i3-volume/volume history 50 >> ~/.volume-history.log

Smart Volume Adjustment

Adjust 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
fi

Run with cron: 0 * * * * ~/scripts/smart-volume.sh

Multi-Sink Volume Sync

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
done

Performance Tips

Reduce Notification Spam

Use notification grouping (dunst only):

NOTIFICATION_GROUP=true

Or disable notifications for rapid changes:

# Disable notifications, use status bar only
DISPLAY_NOTIFICATIONS=false

Optimize Status Bar Updates

Use listen mode instead of polling:

# Good - listens for changes
volume listen "%i %v %p\n"

# Less efficient - polls every interval
# (not recommended)

Cache Sink Information

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.

Creative Use Cases

Volume-Based Automation

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"
fi

Audio Focus Management

Automatically 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 80

Volume Profiles Based on Network

Switch 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
        ;;
esac

Time-Based Volume Limits

Limit 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
fi

Troubleshooting Tips

Dry-Run Mode for Testing

Use 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 5

This 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

Verbose Mode

Use verbose mode to see what's happening:

volume -v up 5

Check Current Configuration

View your current configuration:

volume config show

Validate Configuration

Check for configuration errors:

volume config validate

Test Individual Components

Test 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 switch

Debug Sink Selection

See 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 status

Check Exit Codes

Use exit codes to diagnose issues:

volume up 5
echo "Exit code: $?"

# Or use --exit-code for detailed info
volume --exit-code

Best Practices

1. Use Configuration File

Don'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 5

2. Use Per-Sink Configuration

Configure different settings for different devices:

# Instead of manually adjusting each time
SINK_MAX_VOL[USB Audio]=150
SINK_DEFAULT_STEP[USB Audio]=2

3. Use Profiles

Save common configurations as profiles:

volume profile save quiet
volume profile save loud

4. Use Relative Operations

Relative 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?

5. Combine Features

Combine features for powerful workflows:

# Fade with notifications
volume -n -f 1000 up 10

# Profile with sink switching
volume switch
volume profile gaming

See Also

Clone this wiki locally