From 15b131da12cf4975307d4f7618a1f2902a1a9dc9 Mon Sep 17 00:00:00 2001 From: davidpkj Date: Wed, 17 Apr 2024 18:35:12 +0200 Subject: potato update --- scripts/.local/bin/personal/bar/brightness | 8 ++++---- scripts/.local/bin/personal/bar/ischarging | 15 +++++++++++++++ scripts/.local/bin/personal/bar/smallstatus | 21 +++++++++++++++++++++ scripts/.local/bin/personal/bar/status | 19 +++++++++++++++++-- scripts/.local/bin/personal/themes | 8 +++++--- scripts/.local/bin/personal/volctl | 28 ++++++++++++++++------------ 6 files changed, 78 insertions(+), 21 deletions(-) create mode 100755 scripts/.local/bin/personal/bar/ischarging create mode 100755 scripts/.local/bin/personal/bar/smallstatus (limited to 'scripts') diff --git a/scripts/.local/bin/personal/bar/brightness b/scripts/.local/bin/personal/bar/brightness index b54de59..da28db3 100755 --- a/scripts/.local/bin/personal/bar/brightness +++ b/scripts/.local/bin/personal/bar/brightness @@ -5,10 +5,10 @@ # By David Penkowoj, 2021/06/24 # MTR_DEVICE="$MTR_DEVICE" -MTR_DEVICE="acpi_video0" +MTR_DEVICE="intel_backlight" KBD_DEVICE="smc::kbd_backlight" -MTR_VALUE=99 -KBD_VALUE=0 +MTR_VALUE=49 +KBD_VALUE= SWITCH="$1" @@ -31,7 +31,7 @@ case $SWITCH in "save") M="$(brightnessctl --device="$MTR_DEVICE" | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" K="$(brightnessctl --device="$KBD_DEVICE" | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)" - sed -i "s/MTR_VALUE=$MTR_VALUE/MTR_VALUE=$M/g" "$0" + sed -i "s/MTR_VALUE=49$MTR_VALUE/MTR_VALUE=49$M/g" "$0" sed -i "s/KBD_VALUE=$KBD_VALUE/KBD_VALUE=$K/g" "$0" ;; "smalldown") diff --git a/scripts/.local/bin/personal/bar/ischarging b/scripts/.local/bin/personal/bar/ischarging new file mode 100755 index 0000000..29d736b --- /dev/null +++ b/scripts/.local/bin/personal/bar/ischarging @@ -0,0 +1,15 @@ +#!/bin/bash + +acpireport="$(acpi | grep -v unavailable | head -n 1)" + +state="$(echo $acpireport | awk '{print $3}')" +percent="$(echo $acpireport | sed -n 's/.* \([0-9]\+\)%.*/\1/p')" + +if [[ "${state::-1}" != "Charging" ]]; then + if ((${percent} <= 75)); then + echo "PLUG IN CHARGER" + exit 1 + fi +fi + +exit 0 diff --git a/scripts/.local/bin/personal/bar/smallstatus b/scripts/.local/bin/personal/bar/smallstatus new file mode 100755 index 0000000..09ddd9f --- /dev/null +++ b/scripts/.local/bin/personal/bar/smallstatus @@ -0,0 +1,21 @@ +#!/bin/dash + +flash() { + second="$(date +'%s')" + + if [ $((second % 2)) = 1 ]; then + echo $1 + else + echo $2 + fi +} + +sep="|" + +message="$(volume) $sep $(network) $sep $(temp) $sep $(datetime)" + +if [ ischarging ]; then + echo "$message" +else + flash "NOT CHARGING" "$message" +fi diff --git a/scripts/.local/bin/personal/bar/status b/scripts/.local/bin/personal/bar/status index da46bf0..661b60f 100755 --- a/scripts/.local/bin/personal/bar/status +++ b/scripts/.local/bin/personal/bar/status @@ -12,12 +12,26 @@ use() { printf "%s^c%s^^b%s^ %s ^b%s^ %s ^b%s^" "$SEPARATOR" "$background" "$primary" "$1" "$accent" "$2" "$background" } +flash() { + second="$(date +'%s')" + + if [ "$3" = "1" ]; then + if [ $((second % 2)) = 1 ]; then + printf "%s^c%s^^b%s^ %s ^c%s^^b%s^ %s ^b%s^" "$SEPARATOR" "$color1" "$background" "$1" "$color1" "$background" "$2" "$background" + else + printf "%s^c%s^^b%s^ %s ^c%s^^b%s^ %s ^b%s^" "$SEPARATOR" "$background" "$color1" "$1" "$background" "$color1" "$2" "$background" + fi + else + echo "" + fi +} + # show in specified color if specified condition is true usecolorif() { if [ "$3" = "1" ]; then printf "%s^c%s^^b%s^ %s ^c%s^^b%s^ %s ^b%s^" "$SEPARATOR" "$primary" "$background" "$1" "$accent" "$background" "$2" "$background" else - use "$1" "$2" + echo "" fi } @@ -35,6 +49,7 @@ $(useif "󰍬" "$(mute shortstatus)")\ $(useif "󰕾" "$(volume)")\ $(useif "󰒢" "$(network)")\ $(use "󰘚" "$(load) | $(temp)")\ -$(use "󱐋" "$(battery)")\ +$(flash "󱐋" "$(ischarging)" "$(ischarging > /dev/null; echo $?)")\ $(use "󰃭" "$(datetime)")\ " +# $(use "󱐋" "$(battery)")\ diff --git a/scripts/.local/bin/personal/themes b/scripts/.local/bin/personal/themes index 1bce482..37805a7 100755 --- a/scripts/.local/bin/personal/themes +++ b/scripts/.local/bin/personal/themes @@ -1,6 +1,8 @@ #!/bin/bash -dir="$HOME/.config/wal/colorschemes/dark" -theme=$(ls $dir | dmenu) +dir="$HOME/.config/wal/colorschemes/" +scheme="$(ls $dir | dmenu)" -wally "$dir/$theme" +theme=$(ls "$dir/$scheme" | dmenu) + +wally "$dir/$scheme/$theme" diff --git a/scripts/.local/bin/personal/volctl b/scripts/.local/bin/personal/volctl index 0a3625f..628449e 100755 --- a/scripts/.local/bin/personal/volctl +++ b/scripts/.local/bin/personal/volctl @@ -2,22 +2,26 @@ # A script to manage the volume on my system universally -sink="$(pactl list short sinks | grep "pci-0000_00_1b.0" | awk '{print $1}')" +sink="$(pactl list short sinks | grep "pci-0000_00_1f.3" | awk '{print $1}')" volume="$(pamixer --get-volume)" +last_volume=45 -if [ "$1" = "increase" ] -then +if [ "$1" = "increase" ]; then pactl set-sink-volume "$sink" +5% -elif [ "$1" = "decrease" ] -then + volctl save +elif [ "$1" = "decrease" ]; then pactl set-sink-volume "$sink" -5% -elif [ "$1" = "mute" ] -then - # TODO: Make this a toggle with memory - pactl set-sink-volume "$sink" 0% -elif [ "$1" = "check" ] -then + volctl save +elif [ "$1" = "mute" ]; then + if [ "$volume" = "0" ]; then + pactl set-sink-volume "$sink" "$last_volume%" + else + pactl set-sink-volume "$sink" 0% + fi +elif [ "$1" = "save" ]; then + sed -i "s/last_volume=45$last_volume/last_volume=45$volume/g" "$0" +elif [ "$1" = "check" ]; then printf "%s\n" "$volume" -else +else printf "[ Error ] Not enough arguments.\n" fi -- cgit v1.2.3