Add some scripts
This commit is contained in:
parent
0ec6e946f7
commit
9a48ec9810
8 changed files with 140 additions and 0 deletions
22
bin/backlight.sh
Executable file
22
bin/backlight.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Use brightnessctl to naturally adjust laptop screen brightness and send a notification
|
||||
|
||||
currentbrightness=$(brightnessctl -e4 -m | awk -F, '{print substr($4, 0, length($4)-1)}')
|
||||
if [ "$currentbrightness" -lt 30 ] && [ "$1" = "down" ]; then exit 1; fi
|
||||
|
||||
send_notification() {
|
||||
brightness=$(brightnessctl -e4 -m | awk -F, '{print substr($4, 0, length($4)-1)}')
|
||||
dunstify -a "Backlight" -u low -r 9994 -h int:value:"$brightness" -i "brightness" " Brightness" -t 1000
|
||||
}
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
brightnessctl -e4 set 1%+
|
||||
send_notification "$1"
|
||||
;;
|
||||
down)
|
||||
brightnessctl -e4 set 1%-
|
||||
send_notification "$1"
|
||||
;;
|
||||
esac
|
39
bin/battery-alert.sh
Executable file
39
bin/battery-alert.sh
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Send a notification if the laptop battery is either low or is fully charged.
|
||||
# Set on a systemd timer (~/.config/systemd/user/battery-alert.timer).
|
||||
|
||||
export DISPLAY=:0
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
|
||||
|
||||
# Battery percentage at which to notify
|
||||
WARNING_LEVEL=20
|
||||
CRITICAL_LEVEL=5
|
||||
BATTERY_DISCHARGING=$(acpi -b | grep "Battery 0" | grep -c "Discharging")
|
||||
BATTERY_LEVEL=$(acpi -b | grep "Battery 0" | grep -P -o '[0-9]+(?=%)')
|
||||
|
||||
# Use files to store whether we've shown a notification or not (to prevent multiple notifications)
|
||||
FULL_FILE=/tmp/batteryfull
|
||||
EMPTY_FILE=/tmp/batteryempty
|
||||
CRITICAL_FILE=/tmp/batterycritical
|
||||
|
||||
# Reset notifications if the computer is charging/discharging
|
||||
if [ "$BATTERY_DISCHARGING" -eq 1 ] && [ -f $FULL_FILE ]; then
|
||||
rm $FULL_FILE
|
||||
elif [ "$BATTERY_DISCHARGING" -eq 0 ] && [ -f $EMPTY_FILE ]; then
|
||||
rm $EMPTY_FILE
|
||||
fi
|
||||
|
||||
# If the battery is charging and is full (and has not shown notification yet)
|
||||
if [ "$BATTERY_LEVEL" -gt 99 ] && [ "$BATTERY_DISCHARGING" -eq 0 ] && [ ! -f $FULL_FILE ]; then
|
||||
notify-send "Battery Charged" "Battery is fully charged." -i "battery" -r 9991
|
||||
touch $FULL_FILE
|
||||
# If the battery is low and is not charging (and has not shown notification yet)
|
||||
elif [ "$BATTERY_LEVEL" -le $WARNING_LEVEL ] && [ "$BATTERY_DISCHARGING" -eq 1 ] && [ ! -f $EMPTY_FILE ]; then
|
||||
notify-send "Low Battery" "${BATTERY_LEVEL}% of battery remaining." -u critical -i "battery-alert" -r 9991
|
||||
touch $EMPTY_FILE
|
||||
# If the battery is critical and is not charging (and has not shown notification yet)
|
||||
elif [ "$BATTERY_LEVEL" -le $CRITICAL_LEVEL ] && [ "$BATTERY_DISCHARGING" -eq 1 ] && [ ! -f $CRITICAL_FILE ]; then
|
||||
notify-send "Battery Critical" "The computer will shutdown soon." -u critical -i "battery-alert" -r 9991
|
||||
touch $CRITICAL_FILE
|
||||
fi
|
21
bin/battery-charging.sh
Executable file
21
bin/battery-charging.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Send a notification when the laptop is plugged in/unplugged
|
||||
# Add the following to /etc/udev/rules.d/60-power.rules (replace USERNAME with your user)
|
||||
|
||||
|
||||
|
||||
export XAUTHORITY=~/.Xauthority
|
||||
export DISPLAY=:0
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
|
||||
|
||||
BATTERY_STATE=$1
|
||||
BATTERY_LEVEL=$(acpi -b | grep "Battery 0" | grep -P -o '[0-9]+(?=%)')
|
||||
# My battery takes a couple of seconds to recognize as charging, so this is a hacky way to deal with it
|
||||
case "$BATTERY_STATE" in
|
||||
"charging") BATTERY_CHARGING="Charging" ; BATTERY_ICON="charging" ;;
|
||||
"discharging") BATTERY_CHARGING="Discharging" ; BATTERY_ICON="discharging" ;;
|
||||
esac
|
||||
|
||||
# Send notification
|
||||
notify-send "${BATTERY_CHARGING}" "${BATTERY_LEVEL}% of battery charged." -u normal -i "battery-${BATTERY_ICON}" -t 5000 -r 9991
|
1
bin/chroma
Symbolic link
1
bin/chroma
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/archer/.local/share/pipx/venvs/chromadb/bin/chroma
|
1
bin/langchain-server
Symbolic link
1
bin/langchain-server
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/archer/.local/share/pipx/venvs/langchain/bin/langchain-server
|
1
bin/openai
Symbolic link
1
bin/openai
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/archer/.local/share/pipx/venvs/openai/bin/openai
|
17
bin/pacman-updates.sh
Executable file
17
bin/pacman-updates.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Script for use in waybar to display # of pacman updates
|
||||
|
||||
OUTPUT="$(checkupdates)"
|
||||
|
||||
if [ -z "$OUTPUT" ]; then
|
||||
exit 0
|
||||
else
|
||||
NUMBER="$(echo "$OUTPUT" | wc -l)"
|
||||
TEXT=""
|
||||
|
||||
TOOLTIP="$NUMBER updates found"
|
||||
|
||||
echo "{\"text\":\"""$TEXT""\", \"tooltip\":\"""$TOOLTIP""\"}"
|
||||
exit 0
|
||||
fi
|
38
bin/volume.sh
Executable file
38
bin/volume.sh
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Increment, decrement, or mute the volume using Pipewire and send a notification
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
# Set the volume on (if it was muted)
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
|
||||
wpctl set-volume -l 2.0 @DEFAULT_AUDIO_SINK@ 2%+
|
||||
;;
|
||||
down)
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
|
||||
wpctl set-volume -l 2.0 @DEFAULT_AUDIO_SINK@ 2%-
|
||||
;;
|
||||
mute)
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
|
||||
;;
|
||||
esac
|
||||
|
||||
VOLUME=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | tr -dc '0-9' | sed 's/^0\{1,2\}//')
|
||||
|
||||
|
||||
send_notification() {
|
||||
if [ "$1" = "mute" ]; then ICON="mute"; elif [ "$VOLUME" -lt 33 ]; then ICON="low"; elif [ "$VOLUME" -lt 66 ]; then ICON="medium"; else ICON="high"; fi
|
||||
if [ "$1" = "mute" ]; then TEXT="Currently muted"; else TEXT="Currently at ${VOLUME}%"; fi
|
||||
|
||||
dunstify -a "Volume" -r 9993 -h int:value:"$VOLUME" -i "volume-$ICON" " Volume" "$TEXT" -t 2000
|
||||
}
|
||||
|
||||
case $1 in
|
||||
mute)
|
||||
case "$(wpctl get-volume @DEFAULT_AUDIO_SINK@)" in
|
||||
*MUTED* ) send_notification mute;;
|
||||
* ) send_notification;;
|
||||
esac;;
|
||||
*)
|
||||
send_notification;;
|
||||
esac
|
Loading…
Add table
Add a link
Reference in a new issue