Last active
August 29, 2015 14:06
-
-
Save koyudoon/aa584fdb34630f40e7bd to your computer and use it in GitHub Desktop.
This script generates a volume level indicator for use in Xmobar.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# getVolumeForXmobar.sh | |
# based on: https://bbs.archlinux.org/viewtopic.php?id=74842 | |
# UUID: a9160756-7e31-4daa-a26a-010fe05e762f | |
# 状態の取得 | |
vol=`amixer get Master` | |
# ミュートの場合 | |
vol=${vol%%*\[off\]} | |
vol=${vol:-MM} | |
# 音量部分のみを切り抜く | |
vol=${vol#*\[} | |
vol=${vol%%%\]*} | |
# インジケータの生成 | |
case $vol in | |
1*) vol="[#---------] $vol%" ;; | |
2*) vol="[##--------] $vol%" ;; | |
3*) vol="[###-------] $vol%" ;; | |
4*) vol="[####------] $vol%" ;; | |
5*) vol="[#####-----] $vol%" ;; | |
6*) vol="[######----] $vol%" ;; | |
7*) vol="[#######---] $vol%" ;; | |
8*) vol="[########--] $vol%" ;; | |
9*) vol="[#########-] $vol%" ;; | |
100) vol="[##########]$vol%" ;; | |
*) vol="[----!!----] $vol " ;; | |
esac | |
# 出力 | |
printf '%s' "$vol" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment