#!/bin/sh # volume module for status/stellar # load config module_config [ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc [ "$ENABLE_ITEM4" != "true" ] && exit command -v pactl > /dev/null && BACKEND=pactl || BACKEND=amixer command -v awk > /dev/null || exit # click CLICK() { command -v speedwm-audioctrl > /dev/null || return # values VOL_VOLUME="$(speedwm-audioctrl -getvol)" VOL_ISPULSE="$(speedwm-audioctrl -getbackend)" ICON="$ITEM4_ICON" [ -e "/tmp/speedwm-button" ] && BUTTON="$(cat /tmp/speedwm-button)" || BUTTON="0" [ -z "$TERMINAL" ] && TERMINAL=st [ ! -z "$ICON" ] && ICONSPACING=" " # one character spacing # check value of button case "$BUTTON" in "3") $TERMINAL speedwm-audioctrl -runmixer ; exit ;; esac # send the notification SEND_NOTIF() { FULL_VOL="${ICON}${ICONSPACING}$VOL_VOLUME" notify-send "$FULL_VOL" # some information echo "Notification sent successfully!" echo "INFO: $FULL_VOL" return } command -v notify-send > /dev/null && SEND_NOTIF || echo "FATAL: libnotify not installed, can't send notification." return } # information itself PRINT() { [ "$BACKEND" = "pactl" ] && echo "$(echo $ITEM4_SEPARATOR $ITEM4_ICON $(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5;exit}'))" || echo "$ITEM4_SEPARATOR $ITEM4_ICON $(amixer -c 0 get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/")%)" [ "$ITEM4_SHOW_MUTE" = "true" ] && [ "$BACKEND" = "pactl" ] && pactl get-sink-mute @DEFAULT_SINK@ | grep -q yes && echo " $ITEM4_MUTE_TEXT" } # argument 1 case "$1" in "") CLICK ;; "--print-file") PRINT > /tmp/module_vol ;; "--print") PRINT ;; "--click") CLICK ;; esac