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