diff --git a/bin/backlight.sh b/bin/backlight.sh new file mode 100755 index 0000000..094439c --- /dev/null +++ b/bin/backlight.sh @@ -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 diff --git a/bin/battery-alert.sh b/bin/battery-alert.sh new file mode 100755 index 0000000..0a7004b --- /dev/null +++ b/bin/battery-alert.sh @@ -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 diff --git a/bin/battery-charging.sh b/bin/battery-charging.sh new file mode 100755 index 0000000..680a2c7 --- /dev/null +++ b/bin/battery-charging.sh @@ -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 diff --git a/bin/chroma b/bin/chroma new file mode 120000 index 0000000..90c5c5a --- /dev/null +++ b/bin/chroma @@ -0,0 +1 @@ +/home/archer/.local/share/pipx/venvs/chromadb/bin/chroma \ No newline at end of file diff --git a/bin/langchain-server b/bin/langchain-server new file mode 120000 index 0000000..1b7d2ed --- /dev/null +++ b/bin/langchain-server @@ -0,0 +1 @@ +/home/archer/.local/share/pipx/venvs/langchain/bin/langchain-server \ No newline at end of file diff --git a/bin/openai b/bin/openai new file mode 120000 index 0000000..ce78fc3 --- /dev/null +++ b/bin/openai @@ -0,0 +1 @@ +/home/archer/.local/share/pipx/venvs/openai/bin/openai \ No newline at end of file diff --git a/bin/pacman-updates.sh b/bin/pacman-updates.sh new file mode 100755 index 0000000..752a05a --- /dev/null +++ b/bin/pacman-updates.sh @@ -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 diff --git a/bin/volume.sh b/bin/volume.sh new file mode 100755 index 0000000..2d44f98 --- /dev/null +++ b/bin/volume.sh @@ -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