Skip to content

Instantly share code, notes, and snippets.

@nakamuraos
Last active August 23, 2023 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakamuraos/336eef0e86d6e107136399301bee3ec3 to your computer and use it in GitHub Desktop.
Save nakamuraos/336eef0e86d6e107136399301bee3ec3 to your computer and use it in GitHub Desktop.
Termux GUI: Volume control + Show current volume

Termux GUI / Desktop Environment

Usage

  • Create a folder, for example $HOME/scripts/volume-control
  • Create files with above contents: up.sh, down.sh, mute.sh
  • Add execute perm.: chmod +x *.sh
  • From GUI -> Find program Keyboard -> Tab Application Shortcuts
  • Add 3 shortcuts:
    • /data/data/com.termux/files/home/scripts/volume-control/mute.sh -> AudioMute key
    • /data/data/com.termux/files/home/scripts/volume-control/up.sh -> AudioRaiseVolume key
    • /data/data/com.termux/files/home/scripts/volume-control/down.sh -> AudioLowerVolume key
  • Enjoy!
#!/usr/bin/env bash
# vol down
pactl set-sink-volume @DEFAULT_SINK@ -5%
# get current vol
STATUS=$(pactl list sinks | grep '^[[:space:]]Volume:' | \
head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
# show current vol
notify-send -h int:transient:1 "Volume" "$STATUS%" -t 1500 -r 999999
!/usr/bin/env bash
# mute toggle
pactl set-sink-mute @DEFAULT_SINK@ toggle
# get status mute
STATUS=$(pactl list sinks | grep '^[[:space:]]Mute:' | \
head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([a-z]*\).*,\1,')
# show notify
notify-send -h int:transient:1 "Mute" "$STATUS" -t 1500 -r 999999
#!/usr/bin/env bash
# vol up
pactl set-sink-volume @DEFAULT_SINK@ +5%
# get current vol
STATUS=$(pactl list sinks | grep '^[[:space:]]Volume:' | \
head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
# show current vol
# -t: timeToShow | -r: notifyToReplace
notify-send -h int:transient:1 "Volume" "$STATUS%" -t 1500 -r 999999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment