From 1cace80e4832a5d250ef4b7ccd687996563fb01b Mon Sep 17 00:00:00 2001 From: venomade Date: Thu, 27 Feb 2025 17:06:42 +0000 Subject: Add old dotfiles --- swaywm/local/bin/brightness | 52 ++++++++++++++++++++++++++++++ swaywm/local/bin/i3status++ | 8 +++++ swaywm/local/bin/j4dmenu | 2 ++ swaywm/local/bin/ppctl | 66 ++++++++++++++++++++++++++++++++++++++ swaywm/local/bin/volume | 78 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 206 insertions(+) create mode 100755 swaywm/local/bin/brightness create mode 100755 swaywm/local/bin/i3status++ create mode 100755 swaywm/local/bin/j4dmenu create mode 100755 swaywm/local/bin/ppctl create mode 100755 swaywm/local/bin/volume (limited to 'swaywm/local') diff --git a/swaywm/local/bin/brightness b/swaywm/local/bin/brightness new file mode 100755 index 0000000..2c8ebb4 --- /dev/null +++ b/swaywm/local/bin/brightness @@ -0,0 +1,52 @@ +#!/bin/bash + +function get_brightness { + cntb=$(brightnessctl g) + maxb=$(brightnessctl m) + + echo $(( ($cntb * 100) / $maxb )) +} + +# Function to get the icon based on the brightness level +function get_brightness_icon { + brightness_level=$1 + if [ $brightness_level -le 33 ]; then + echo "󰃞" + elif [ $brightness_level -le 66 ]; then + echo "󰃟" + else + echo "󰃠" + fi +} + +# Function to set the contents of "/tmp/brightness_status" to the current brightness level +function set_tmp_brightness_status { + brightness_level=$(get_brightness) + icon=$(get_brightness_icon $brightness_level) + echo "$icon $brightness_level%" > /tmp/brightness_status +} + +function send_notification { + brightness_level=$(get_brightness) + icon=$(get_brightness_icon $brightness_level) + # Make the bar with the special character ─ (it's not dash -) + # https://en.wikipedia.org/wiki/Box-drawing_character + bar=$(seq -s "─" $(($brightness_level / 5)) | sed 's/[0-9]//g') + # Send the notification + dunstify -i display-brightness-symbolic -t 2500 -r 2593 -u normal " $bar" +} + +case $1 in + up) + # Set the brightness level up (+ 5%) + brightnessctl s 5%+ + send_notification + set_tmp_brightness_status + ;; + down) + # Set the brightness level down (- 5%) + brightnessctl s 5%- + send_notification + set_tmp_brightness_status + ;; +esac diff --git a/swaywm/local/bin/i3status++ b/swaywm/local/bin/i3status++ new file mode 100755 index 0000000..ea4ede6 --- /dev/null +++ b/swaywm/local/bin/i3status++ @@ -0,0 +1,8 @@ +#!/bin/bash + +i3status | (read line; echo "$line"; read line ; echo "$line" ; read line ; echo "$line" ; while true +do + read line + json_array="$(echo $line | sed -e 's/^,//')" + echo ",$json_array" +done) \ No newline at end of file diff --git a/swaywm/local/bin/j4dmenu b/swaywm/local/bin/j4dmenu new file mode 100755 index 0000000..6d63196 --- /dev/null +++ b/swaywm/local/bin/j4dmenu @@ -0,0 +1,2 @@ +#!/bin/bash +j4-dmenu-desktop --dmenu="dmenu -fn 'ZedMono Nerd Font-12' -i -b -nb '#000000' -nf '#ffffff' -sb '#b299db' -sf '#000000' -p 'drun>'" \ No newline at end of file diff --git a/swaywm/local/bin/ppctl b/swaywm/local/bin/ppctl new file mode 100755 index 0000000..6babda5 --- /dev/null +++ b/swaywm/local/bin/ppctl @@ -0,0 +1,66 @@ +#!/bin/bash + +function set_profile { + case $1 in + performance) + powerprofilesctl set performance + ;; + balanced) + powerprofilesctl set balanced + ;; + power-saver) + powerprofilesctl set power-saver + ;; + *) + echo "Invalid profile. Please use 'performance', 'balanced', or 'power-saver'." + ;; + esac +} + +function get_profile { + powerprofilesctl get +} + +function get_nficon { + profile=$1 + case $profile in + performance) + echo "󰓅" + ;; + balanced) + echo "󰾅" + ;; + power-saver) + echo "󰾆" + ;; + *) + echo "Invalid profile" + ;; + esac +} + +function send_notification { + profile=$(get_profile) + icon="power-profile-$profile-symbolic" + # Send the notification + dunstify -i $icon -t 2500 -r 2593 -u normal "Power Profile: $profile" +} + +# Function to set the contents of "/tmp/powerprofile" to the current profile +function set_tmp_powerprofile { + profile=$(get_profile) + nficon=$(get_nficon $profile) + echo "$nficon $profile" > /tmp/powerprofile +} + +case $1 in + performance|balanced|power-saver) + set_profile $1 + send_notification + set_tmp_powerprofile + ;; + *) + echo "Usage: $0 {performance|balanced|power-saver}" + exit 1 + ;; +esac diff --git a/swaywm/local/bin/volume b/swaywm/local/bin/volume new file mode 100755 index 0000000..eb662b4 --- /dev/null +++ b/swaywm/local/bin/volume @@ -0,0 +1,78 @@ +#!/bin/bash + +function get_volume { + pactl get-sink-volume @DEFAULT_SINK@ | awk '/Volume:/ {print $5}' | cut -d '/' -f 1 | sed 's/%//g' +} + +function is_mute { + #amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null + pactl list sinks | grep -A 10 'State: ' | grep -q 'Mute: yes' +} + +function is_mic_mute { + pactl list sources | grep -A 10 'State: ' | grep -q 'Mute: yes' +} + +function get_icon { + volume=$(get_volume) + if is_mute; then + echo "audio-volume-muted-symbolic" + elif (( volume <= 39 )); then + echo "audio-volume-low-symbolic" + elif (( volume <= 74 )); then + echo "audio-volume-medium-symbolic" + elif (( volume <= 100 )); then + echo "audio-volume-high-symbolic" + else + echo "audio-volume-overamplified-symbolic" + fi +} + +function send_notification { + volume=$(get_volume) + icon=$(get_icon) + # 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 "$icon" -t 2500 -r 2593 -u normal " $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 pu lse sset Master 5%+ > /dev/null + volume=$(get_volume) + if [[ $volume -le 99 ]]; then + pactl set-sink-volume @DEFAULT_SINK@ +5% + else + pactl set-sink-volume @DEFAULT_SINK@ 100% + fi + send_notification + ;; + down) + # amixer -D pulse set Master on > /dev/null + # amixer -D pulse sset Master 5%- > /dev/null + pactl set-sink-volume @DEFAULT_SINK@ -5% + send_notification + ;; + mute) + # Toggle mute + pactl set-sink-mute @DEFAULT_SINK@ toggle + if is_mute ; then + dunstify -i audio-volume-muted -t 2500 -r 2593 -u normal "Mute" + else + send_notification + fi + ;; + mute-mic) + pactl set-source-mute @DEFAULT_SOURCE@ toggle + if is_mic_mute ; then + dunstify -i microphone-sensitivity-muted-symbolic -t 2500 -r 2593 -u normal "Microphone Muted" + else + dunstify -i microphone-sensitivity-high-symbolic -t 2500 -r 2593 -u normal "Microphone Unmuted" + fi + ;; +esac -- cgit 1.4.1-2-gfad0