diff --git a/.gitignore b/.gitignore index c4ba3e5..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +0,0 @@ -serverssh -.gitignore diff --git a/daemons/battery-daemon b/daemons/battery-daemon new file mode 100644 index 0000000..ea05e40 --- /dev/null +++ b/daemons/battery-daemon @@ -0,0 +1,5 @@ +#!/bin/bash +while true; do + ~/.scripts/notifs/battery + sleep 1 +done diff --git a/notifs/battery b/notifs/battery new file mode 100755 index 0000000..6fb6c55 --- /dev/null +++ b/notifs/battery @@ -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" diff --git a/notifs/battery-status b/notifs/battery-status new file mode 100755 index 0000000..5222e75 --- /dev/null +++ b/notifs/battery-status @@ -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 diff --git a/notifs/brightness b/notifs/brightness new file mode 100755 index 0000000..cec2e0b --- /dev/null +++ b/notifs/brightness @@ -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 diff --git a/notifs/charge-status b/notifs/charge-status new file mode 100755 index 0000000..c8c447e --- /dev/null +++ b/notifs/charge-status @@ -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 diff --git a/notifs/time b/notifs/time new file mode 100755 index 0000000..f8471a5 --- /dev/null +++ b/notifs/time @@ -0,0 +1,4 @@ +#!/bin/bash +CURRENT_TIME=$(date) + +notify-send "Date / Time Info:" "${CURRENT_TIME}" -t 5000 -r 9991 diff --git a/notifs/volume b/notifs/volume new file mode 100755 index 0000000..9202784 --- /dev/null +++ b/notifs/volume @@ -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 diff --git a/wayshot2.sh b/screenshot similarity index 70% rename from wayshot2.sh rename to screenshot index 4fcb854..c03da55 100755 --- a/wayshot2.sh +++ b/screenshot @@ -1,30 +1,30 @@ #!/bin/bash - ## Variables declare -r time=$(date --iso-8601=seconds) - -while(( $# > 0)); do +while (($# > 0)); do case $1 in - -s) + -s) REGION=yes shift ;; - -c) + + -c) CURSOR=yes shift ;; - *) + + *) if [ -z "$FILENAME" ]; then - FILENAME="$1/$time.png" - shift + FILENAME="$1/$time.png" + shift else - echo "wrong format" - exit 1 + echo "wrong format" + exit 1 fi ;; -esac + esac done OPTS=() @@ -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" diff --git a/ssh_and_gpg.py b/ssgpg similarity index 99% rename from ssh_and_gpg.py rename to ssgpg index d9e832a..637470a 100644 --- a/ssh_and_gpg.py +++ b/ssgpg @@ -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 diff --git a/sunset.sh b/sunset similarity index 92% rename from sunset.sh rename to sunset index a7d016b..8868890 100755 --- a/sunset.sh +++ b/sunset @@ -9,6 +9,6 @@ if [[ $(pgrep gammastep) =~ ^[0-9]+$ ]] kill $(pgrep gammastep) else - gammastep -PO 3200 + gammastep -PO 2900 fi