From c90f3ac09e9a6d09606e8ae563057e03f2a996f1 Mon Sep 17 00:00:00 2001 From: RealStickman Date: Sat, 10 Oct 2020 14:39:26 +0200 Subject: [PATCH] Added script for dunst volume and iommu-group detection --- arch-config/scripts/dunst-volume.sh | 47 +++++++++++++++++++++++++++++ arch-config/scripts/iommu.sh | 8 +++++ 2 files changed, 55 insertions(+) create mode 100644 arch-config/scripts/dunst-volume.sh create mode 100755 arch-config/scripts/iommu.sh diff --git a/arch-config/scripts/dunst-volume.sh b/arch-config/scripts/dunst-volume.sh new file mode 100644 index 00000000..56b8bef9 --- /dev/null +++ b/arch-config/scripts/dunst-volume.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# You can call this script like this: +# $./volume.sh up +# $./volume.sh down +# $./volume.sh mute + +get_volume() { + amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1 +} + +is_mute() { + amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null +} + +send_notification() { + volume=$(get_volume) + # Make the bar with the special character ─ (it's not dash -) + # https://en.wikipedia.org/wiki/Box-drawing_character + bar=$(seq -s "─" $(($volume / 5)) | sed 's/[0-9]//g') + # Send the notification + dunstify -i audio-volume-high -r 2593 " $bar" +} + +case $1 in + up) + # Set the volume on (if it was muted) + amixer -D pulse set Master on > /dev/null + # Up the volume (+ 5%) + amixer -D pulse sset Master 5%+ > /dev/null + send_notification + ;; + down) + amixer -D pulse set Master on > /dev/null + amixer -D pulse sset Master 5%- > /dev/null + send_notification + ;; + mute) + # Toggle mute + amixer -D pulse set Master 1+ toggle > /dev/null + if is_mute ; then + dunstify -i audio-volume-muted -r 2593 -u normal "Mute" + else + send_notification + fi + ;; +esac diff --git a/arch-config/scripts/iommu.sh b/arch-config/scripts/iommu.sh new file mode 100755 index 00000000..e3559fb0 --- /dev/null +++ b/arch-config/scripts/iommu.sh @@ -0,0 +1,8 @@ +#!/bin/bash +shopt -s nullglob +for g in /sys/kernel/iommu_groups/*; do + echo "IOMMU Group ${g##*/}:" + for d in $g/devices/*; do + echo -e "\t$(lspci -nns ${d##*/})" + done; +done; \ No newline at end of file