feat: added notifications & daemons + simplified naming
notifications are for `dunst` a notification handler for my setup I added volume, charging, battery, time, and brightness notifications
This commit is contained in:
parent
413b470d99
commit
9b374bb70d
11 changed files with 281 additions and 15 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
|||
serverssh
|
||||
.gitignore
|
||||
5
daemons/battery-daemon
Normal file
5
daemons/battery-daemon
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
while true; do
|
||||
~/.scripts/notifs/battery
|
||||
sleep 1
|
||||
done
|
||||
73
notifs/battery
Executable file
73
notifs/battery
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Constants (access to display)
|
||||
export DISPLAY=:0
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
|
||||
|
||||
# Find out which battery is the laptop's battery
|
||||
BATTERY=$(acpi | grep -vwE "(unavailable)" | grep -o '[0-9]' | head -n 1)
|
||||
|
||||
# Daemon Constants
|
||||
WARNING_PERCENT=35
|
||||
FULL_PERCENT=99
|
||||
BAT_PERCENT=$(acpi -b | grep "Battery $BATTERY" | head -n 1 | grep -P -o "[0-9]+(?=%)")
|
||||
DISCHARGING_COUNT=$(acpi -b | grep "Battery $BATTERY" | grep -c "Discharging")
|
||||
NOTCHARGING_COUNT=$(acpi -b | grep "Battery $BATTERY" | grep "until" | grep -c "Not Charging")
|
||||
## Conditioning Files
|
||||
LOW_BAT_FILE=/tmp/battery_low
|
||||
FULL_BAT_FILE=/tmp/battery_full
|
||||
|
||||
# Functions
|
||||
battery-full() {
|
||||
notify-send "Battery Full" "Battery is fully charged!" -i "battery-full-charged" -r 9991 -t 5000
|
||||
touch $FULL_BAT_FILE
|
||||
}
|
||||
|
||||
battery-low() {
|
||||
notify-send "Low Battery" "${BAT_PERCENT}% of battery remaining." -u critical -i "battery-caution" -r 9991
|
||||
touch $LOW_BAT_FILE
|
||||
}
|
||||
|
||||
battery-normal() {
|
||||
if [ "$1" == "Normal" ]; then
|
||||
rm $FULL_BAT_FILE
|
||||
|
||||
elif [ "$1" == "Charging" ]; then
|
||||
rm $LOW_BAT_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
# IF the batttery is discharging AND there is a FULL_BAT_FILE exists AND battery is less than 99%
|
||||
if [ "$BAT_PERCENT" -lt $FULL_PERCENT ] && [ "$DISCHARGING_COUNT" -eq 1 ] && [ -f $FULL_BAT_FILE ]; then
|
||||
#echo "hit normal + full file exists + less than full %"
|
||||
battery-normal "Normal"
|
||||
|
||||
# If charging, AND less than full percentage AND LOW_BAT_FILE exists:
|
||||
elif [ "$BAT_PERCENT" -lt $FULL_PERCENT ] && [ "$DISCHARGING_COUNT" -eq 0 ] && [ -f "$EMPTY_BAT_FILE" ]; then
|
||||
#echo "hit normal + warning file exists + more than warning %"
|
||||
battery-normal "Charging"
|
||||
fi
|
||||
|
||||
# IF the battery is charging AND is full (+ hasn't show any notif yet):
|
||||
if [ "$BAT_PERCENT" -ge $FULL_PERCENT ] && [ ! -f $FULL_BAT_FILE ] && [ "$DISCHARGING_COUNT" = 0 ]; then
|
||||
#echo "hit full + charging"
|
||||
battery-full
|
||||
|
||||
# Another condition, battery could be full, yet it won't be charging:
|
||||
elif [ "$BAT_PERCENT" -ge $FULL_PERCENT ] && [ "$NOTCHARGING_COUNT" = 1 ] && [ ! -f $LOW_BAT_FILE ]; then
|
||||
#echo "hit full + not charging"
|
||||
battery-full
|
||||
|
||||
# IF the battery is low and it's discharging (+ hasn't shown any notif yet):
|
||||
elif [ "$BAT_PERCENT" -le $WARNING_PERCENT ] && [ "$DISCHARGING_COUNT" -eq 1 ] && [ ! -f $LOW_BAT_FILE ]; then
|
||||
#echo "hit low + discharging"
|
||||
battery-low
|
||||
|
||||
# If LOW_BAT_FILE Exists, Spam Until It's Charging
|
||||
elif [ "$BAT_PERCENT" -le $WARNING_PERCENT ] && [ "$DISCHARGING_COUNT" -eq 1 ] && [ -f $LOW_BAT_FILE ]; then
|
||||
notify-send "Low Battery" "${BAT_PERCENT}% of battery remaining." -u critical -i "battery-caution" -r 9991
|
||||
fi
|
||||
|
||||
# Debug commands
|
||||
echo "$BAT_PERCENT is the battery percent"
|
||||
echo "$DISCHARGING_COUNT -- 1 = discharging, 0 = charging"
|
||||
11
notifs/battery-status
Executable file
11
notifs/battery-status
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
BATTERY=$(acpi | grep -vwE "(unavailable)" | grep -o '[0-9]' | head -n 1)
|
||||
BAT_PERCENT=$(acpi -b | grep "Battery $BATTERY" | grep -P -o "[0-9]+(?=%)")
|
||||
DISCHARGING_COUNT=$(acpi -b | grep "Battery $BATTERY" | grep "until" | grep -c "Discharging")
|
||||
#NOTCHARGING_COUNT=$(acpi -b | head -n 1 | grep -c "Not Charging")
|
||||
|
||||
if [[ $DISCHARGING_COUNT -eq 0 ]]; then
|
||||
dunstify "Battery Status" "Battery is currently charging at ${BAT_PERCENT}%" -i "battery-level-50-charging-symbolic" -r 9991 -t 5000
|
||||
else
|
||||
dunstify "Battery Status" "Battery is currently at ${BAT_PERCENT}%" -i "battery-level-50-symbolic" -r 9991 -t 5000
|
||||
fi
|
||||
24
notifs/brightness
Executable file
24
notifs/brightness
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
CURRENT_BRIGHTNESS=$(xbacklight -get)
|
||||
|
||||
bright_inc() {
|
||||
dunstify "Increasing Brightness" "Current Brightness: ${CURRENT_BRIGHTNESS}%" -i "display-brightness-medium-symbolic" -t 5000 -r 9991
|
||||
}
|
||||
|
||||
bright_dec() {
|
||||
dunstify "Decreasing Brightness" "Current Brightness: ${CURRENT_BRIGHTNESS}%" -i "display-brightness-low-symbolic" -t 5000 -r 9991
|
||||
|
||||
}
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
inc)
|
||||
bright_inc && exit 0
|
||||
;;
|
||||
|
||||
dec)
|
||||
bright_dec && exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
28
notifs/charge-status
Executable file
28
notifs/charge-status
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
export DISPLAY=:0
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
|
||||
|
||||
# Find out which battery is the laptop's battery
|
||||
BATTERY=$(acpi | grep -vwE "(unavailable)" | grep -o '[0-9]' | head -n 1)
|
||||
|
||||
# 1 = Charging
|
||||
# 0 = Discharging
|
||||
BAT_CHARGING=$1
|
||||
|
||||
# Filtering one more time to find the percentage of the laptop's battery level
|
||||
BAT_LEVEL=$(acpi -b | grep "Battery $BATTERY" | grep -P -o '[0-9]+(?=%)')
|
||||
|
||||
CHARGE_FILE=/tmp/laptop-charging
|
||||
DISCHARGE_FILE=/tmp/laptop-discharging
|
||||
|
||||
# Notification handling
|
||||
if [ "$BAT_CHARGING" -eq 1 ] && [ ! -f $CHARGE_FILE ]; then
|
||||
rm $DISCHARGE_FILE
|
||||
touch $CHARGE_FILE
|
||||
/usr/bin/notify-send "Charging" "Charging battery at ${BAT_LEVEL}%" -u low -i "battery-level-50-charging-symbolic" -t 5000 -r 9991
|
||||
elif [ "$BAT_CHARGING" -eq 0 ] && [ ! -f $DISCHARGE_FILE ]; then
|
||||
rm $CHARGE_FILE
|
||||
touch $DISCHARGE_FILE
|
||||
/usr/bin/notify-send "Discharging" "${BAT_LEVEL}% remaining" -u low -i "battery-level-70-symbolic" -t 5000 -r 9991
|
||||
fi
|
||||
4
notifs/time
Executable file
4
notifs/time
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
CURRENT_TIME=$(date)
|
||||
|
||||
notify-send "Date / Time Info:" "${CURRENT_TIME}" -t 5000 -r 9991
|
||||
122
notifs/volume
Executable file
122
notifs/volume
Executable file
|
|
@ -0,0 +1,122 @@
|
|||
#!/bin/bash
|
||||
|
||||
CURRENT_VOL=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{ print $2 }')
|
||||
VOL_PRESENT=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{ print $2 }' | cut -c 3,4)
|
||||
|
||||
CURRENT_MIC_VOL=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | awk '{ print $2 }')
|
||||
MIC_PRESENT=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | awk '{ print $2 }' | cut -c 3,4)
|
||||
|
||||
CURRENT_MUTE=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{ print $3 }' | tr -d '[]')
|
||||
CURRENT_MIC_MUTE=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | awk '{ print $3 }' | tr -d '[]')
|
||||
|
||||
vol_inc() {
|
||||
if [[ "$CURRENT_VOL" == "0.0"* ]]; then
|
||||
dunstify "Increasing Volume" "Current Volume: $(echo "$VOL_PRESENT" | cut -c 2)%" -i "audio-volume-high" -t 5000 -r 9991
|
||||
elif [[ "$CURRENT_VOL" == "1.00" ]]; then
|
||||
dunstify "Increasing Volume" "Current Volume: 100%" -i "audio-volume-high" -t 5000 -r 9991
|
||||
else
|
||||
dunstify "Increasing Volume" "Current Volume: ${VOL_PRESENT}%" -i "audio-volume-high" -t 5000 -r 9991
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
vol_dec() {
|
||||
if [[ "$CURRENT_VOL" == "0.0"* ]]; then
|
||||
dunstify "Decreasing Volume" "Current Volume: $(echo "$VOL_PRESENT" | cut -c 2)%" -i "audio-volume-medium" -t 5000 -r 9991
|
||||
elif [[ "$CURRENT_VOL" == "1.00" ]]; then
|
||||
dunstify "Decreasing Volume" "Current Volume: 100%" -i "audio-volume-medium" -t 5000 -r 9991
|
||||
else
|
||||
dunstify "Decreasing Volume" "Current Volume: ${VOL_PRESENT}%" -i "audio-volume-medium" -t 5000 -r 9991
|
||||
fi
|
||||
}
|
||||
|
||||
vol_mute_toggle() {
|
||||
# If "MUTED" doesn't exist, then send notification and toggle mute, otherwise (if "MUTED" DOES exist, send notif and unmute
|
||||
if [ "$CURRENT_MUTE" == "MUTED" ]; then
|
||||
if [[ "$CURRENT_VOL" == "0.0"* ]]; then
|
||||
dunstify "Currently Muting" "Current Volume: $(echo "$VOL_PRESENT" | cut -c 2)%" -i "audio-volume-muted" -t 5000 -r 9991
|
||||
elif [[ "$CURRENT_VOL" == "1.00" ]]; then
|
||||
dunstify "Currently Muting" "Current Volume: 100%" -i "audio-volume-muted" -t 5000 -r 9991
|
||||
else
|
||||
dunstify "Currently Muting" "Current Volume: ${VOL_PRESENT}%" -i "audio-volume-muted" -t 5000 -r 9991
|
||||
fi
|
||||
else
|
||||
if [[ "$CURRENT_VOL" == "0.0"* ]]; then
|
||||
dunstify "Currently Unmuting" "Current Volume: $(echo "$VOL_PRESENT" | cut -c 2)%" -i "audio-volume-medium" -t 5000 -r 9991
|
||||
elif [[ "$CURRENT_VOL" == "1.00" ]]; then
|
||||
dunstify "Currently Unmuting" "Current Volume: 100%" -i "audio-volume-medium" -t 5000 -r 9991
|
||||
else
|
||||
dunstify "Currently Unmuting" "Current Volume: ${VOL_PRESENT}%" -i "audio-volume-medium" -t 5000 -r 9991
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
micInc() {
|
||||
if [[ "$CURRENT_MIC_VOL" == "0.0"* ]]; then
|
||||
dunstify "Increasing Microphone Volume" "Current Volume: $(echo "$MIC_PRESENT" | cut -c 2)%" -i "audio-input-microphone-high" -t 5000 -r 9991
|
||||
elif [[ "$CURRENT_MIC_VOL" == "1.00" ]]; then
|
||||
dunstify "Increasing Microphone Volume" "Current Volume: 100%" -i "audio-input-microphone-high" -t 5000 -r 9991
|
||||
else
|
||||
dunstify "Increasing Microphone Volume" "Current Volume: ${MIC_PRESENT}%" -i "audio-input-microphone-high" -t 5000 -r 9991
|
||||
fi
|
||||
}
|
||||
|
||||
micDec() {
|
||||
if [[ "$CURRENT_MIC_VOL" == "0.0"* ]]; then
|
||||
dunstify "Decreasing Microphone Volume" "Current Volume: $(echo "$MIC_PRESENT" | cut -c 2)%" -i "audio-input-microphone-low" -t 5000 -r 9991
|
||||
elif [[ "$CURRENT_MIC_VOL" == "1.00" ]]; then
|
||||
dunstify "Decreasing Microphone Volume" "Current Volume: 100%" -i "audio-input-microphone-low" -t 5000 -r 9991
|
||||
else
|
||||
dunstify "Decreasing Microphone Volume" "Current Volume: ${MIC_PRESENT}%" -i "audio-input-microphone-low" -t 5000 -r 9991
|
||||
fi
|
||||
}
|
||||
|
||||
mic_mute_toggle() {
|
||||
# If "MUTED" doesn't exist, then send notification and toggle mute, otherwise (if "MUTED" DOES exist, send notif and unmute
|
||||
if [ "$CURRENT_MIC_MUTE" == "MUTED" ]; then
|
||||
if [[ "$CURRENT_MIC_VOL" == "0.0"* ]]; then
|
||||
dunstify "Currently Muting Microphone" "Current Volume: $(echo "$VOL_PRESENT" | cut -c 2)%" -i "audio-input-microphone-muted" -t 5000 -r 9991
|
||||
elif [[ "$CURRENT_MIC_VOL" == "1.00" ]]; then
|
||||
dunstify "Currently Muting Microphone" "Current Volume: 100%" -i "audio-input-microphone-muted" -t 5000 -r 9991
|
||||
else
|
||||
dunstify "Currently Muting Microphone" "Current Volume: ${VOL_PRESENT}%" -i "audio-input-microphone-muted" -t 5000 -r 9991
|
||||
fi
|
||||
else
|
||||
if [[ "$CURRENT_MIC_VOL" == "0.0"* ]]; then
|
||||
dunstify "Currently Unmuting Microphone" "Current Volume: $(echo "$VOL_PRESENT" | cut -c 2)%" -i "audio-input-microphone-high" -t 5000 -r 9991
|
||||
elif [[ "$CURRENT_MIC_VOL" == "1.00" ]]; then
|
||||
dunstify "Currently Unmuting Microphone" "Current Volume: 100%" -i "audio-input-microphone-high" -t 5000 -r 9991
|
||||
else
|
||||
dunstify "Currently Unmuting Microphone" "Current Volume: ${VOL_PRESENT}%" -i "audio-input-microphone-high" -t 5000 -r 9991
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
inc)
|
||||
vol_inc && exit 0
|
||||
;;
|
||||
|
||||
dec)
|
||||
vol_dec && exit 0
|
||||
;;
|
||||
|
||||
mute-toggle)
|
||||
vol_mute_toggle && exit 0
|
||||
;;
|
||||
|
||||
micInc)
|
||||
micInc && exit 0
|
||||
;;
|
||||
|
||||
micDec)
|
||||
micDec && exit 0
|
||||
;;
|
||||
|
||||
micMute)
|
||||
mic_mute_toggle && exit 0
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
## Variables
|
||||
declare -r time=$(date --iso-8601=seconds)
|
||||
|
||||
|
||||
while (($# > 0)); do
|
||||
case $1 in
|
||||
-s)
|
||||
REGION=yes
|
||||
shift
|
||||
;;
|
||||
|
||||
-c)
|
||||
CURSOR=yes
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
if [ -z "$FILENAME" ]; then
|
||||
FILENAME="$1/$time.png"
|
||||
|
|
@ -38,4 +38,4 @@ fi
|
|||
|
||||
grim "${OPTS[@]}" "$FILENAME"
|
||||
# https://github.com/bugaevc/wl-clipboard/issues/198 lifesaver
|
||||
wl-copy --type image/png < $FILENAME
|
||||
wl-copy --type image/png <"$FILENAME"
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#!/bin/python
|
||||
# Made by Devaine
|
||||
# mostly because bash was pissing me off when it comes to recursion
|
||||
# also because i am lazy and i wanted to automate things
|
||||
|
|
@ -9,6 +9,6 @@ if [[ $(pgrep gammastep) =~ ^[0-9]+$ ]]
|
|||
kill $(pgrep gammastep)
|
||||
|
||||
else
|
||||
gammastep -PO 3200
|
||||
gammastep -PO 2900
|
||||
fi
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue