feat(scripts): Huge updates
This commit is contained in:
1 parent
02ac88ed8a
commit
5d07d2d2a5
12 files changed
+94
-347
No files matched your search
@@ -17,4 +17,4 @@ env = XDG_SESSION_TYPE,wayland
|
||||
env = MOZ_ENABLE_WAYLAND,1 firefox
|
||||
|
||||
# Cursor size
|
||||
env = XCURSOR_SIZE,6
|
||||
env = XCURSOR_SIZE,1
|
||||
@@ -4,7 +4,7 @@ $scriptsDir = $HOME/.config/hypr/scripts
|
||||
$wallDIR=$HOME/Pictures/wallpapers
|
||||
|
||||
$RunCMD = $scriptsDir/RunCMD.sh
|
||||
$SwwwRandom = $RunCMD autowall
|
||||
$SwwwRandom = $RunCMD auto_wall
|
||||
$lock = $RunCMD lockscreen
|
||||
|
||||
# wallpaper stuff / More wallpaper options below
|
||||
@@ -19,10 +19,7 @@ exec-once = systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESK
|
||||
exec-once = $scriptsDir/Polkit.sh
|
||||
|
||||
# Battery Notification
|
||||
exec-once = $scriptsDir/BatteryNotify.sh
|
||||
|
||||
# Welcome Message
|
||||
exec-once = $RunCMD welcome
|
||||
exec-once = $RunCMD battery_notify
|
||||
|
||||
# starup apps
|
||||
exec-once = waybar &
|
||||
@@ -37,8 +34,12 @@ exec-once = bluetoothctl power off &
|
||||
exec-once = wl-paste --type text --watch cliphist store
|
||||
exec-once = wl-paste --type image --watch cliphist store
|
||||
|
||||
|
||||
# Welcome Message
|
||||
#exec-once = $RunCMD welcome
|
||||
|
||||
# Rainbow borders
|
||||
#exec-once = $RunCMD rainbowborder
|
||||
#exec-once = $RunCMD rainbow_border
|
||||
|
||||
# sway-idle with lock only
|
||||
#exec-once = swayidle -w timeout 900 '$lock'
|
||||
|
||||
@@ -13,7 +13,7 @@ $RunCMD = $scriptsDir/RunCMD.sh
|
||||
|
||||
|
||||
# RunCMD App launcher
|
||||
bindr = $mainMod, $mainMod_L, exec, pkill rofi || rofi -show drun -modi drun,filebrowser,run,window -config ~/.config/rofi/launcher.rasi
|
||||
#bindr = $mainMod, $mainMod_L, exec, pkill rofi || rofi -show drun -modi drun,filebrowser,run,window -config ~/.config/rofi/launcher.rasi
|
||||
bind = $mainMod, D, exec, pkill rofi || rofi -show drun -modi drun,filebrowser,run,window -config ~/.config/rofi/launcher.rasi
|
||||
bind = ALT, D, exec, pkill rofi || $scriptsDir/Xmenu.sh
|
||||
|
||||
@@ -30,17 +30,18 @@ bind = $mainMod, Slash, exec, kitty nvim
|
||||
bind = $mainMod_SHIFT, Slash, exec, codium --disable-gpu
|
||||
|
||||
# FEATURES / EXTRAS
|
||||
bind = SHIFT_ALT, R, exec, $RunCMD reloadall
|
||||
bind = SHIFT_ALT, R, exec, $RunCMD reload_all
|
||||
bind = $mainMod_SHIFT, D, exec, $RunCMD toggle_touchpad
|
||||
bind = $mainMod, X, exec, $RunCMD powermenu
|
||||
bind = $mainMod_SHIFT, A, exec, $RunCMD gamemode
|
||||
bind = ALT, slash, exec, $RunCMD emoji
|
||||
bind = ALT, F1, exec, $RunCMD kb
|
||||
bind = $mainMod_SHIFT, Q, exec, $RunCMD blur
|
||||
bind = $mainMod, space, exec, $RunCMD layout
|
||||
bind = ALT, F1, exec, $RunCMD kb_changer
|
||||
bind = $mainMod_SHIFT, Q, exec, $RunCMD toggle_blur
|
||||
bind = $mainMod, space, exec, $RunCMD change_layout
|
||||
bind = SHIFT_ALT, C, exec, $RunCMD clip
|
||||
bind = ALT, E, exec, $RunCMD edit
|
||||
bind = $mainMod, W, exec, $RunCMD selectwall
|
||||
bind = SHIFT_ALT,W, exec, $RunCMD randomwall
|
||||
bind = $mainMod, W, exec, $RunCMD select_wall
|
||||
bind = SHIFT_ALT,W, exec, $RunCMD random_wall
|
||||
bind = $mainMod, F1, exec, $RunCMD keybind
|
||||
bind = ALT_SHIFT, T, exec, $RunCMD todo
|
||||
bind = ALT, T, exec, $RunCMD tmux
|
||||
@@ -59,6 +60,6 @@ bind = ALT, R, exec, $RunCMD music -k # Resume
|
||||
|
||||
# Waybar / Bar related
|
||||
bind = $mainMod, H, exec, killall -SIGUSR1 waybar
|
||||
bind = ALT, W, exec, $RunCMD waybarl
|
||||
bind = ALT, W, exec, $RunCMD waybar_layout
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
#? Full battery threshold (default: 100%)
|
||||
battery_full_threshold=100
|
||||
#? Critical battery threshold (default: 10%)
|
||||
battery_critical_threshold=20
|
||||
#? Low battery threshold (default: 20%)
|
||||
battery_low_threshold=40
|
||||
#? Unplug charger threshold (default: 80%)
|
||||
unplug_charger_threshold=80
|
||||
#? Countdown timer before executing execute_critical (default: 120 seconds)
|
||||
timer=120
|
||||
#? Notify interval for Battery Full Status (default: 1140 mins/ 1 day)
|
||||
notify=1140
|
||||
#? Notify interval on LOW and UNPLUG Status (default: 5%)
|
||||
interval=3
|
||||
#? Shows Battery Plug In/Out/Full Notification
|
||||
undock=true
|
||||
#? Command/script to execute at minimum unplug_charger_threshold
|
||||
execute_unplug=""
|
||||
#? Command/script to execute at maximum battery_low_threshold
|
||||
execute_low=""
|
||||
#? Command/script to execute if battery on critical threshold (default: systemctl suspend)
|
||||
execute_critical="systemctl suspend"
|
||||
#? Command/script to execute when battery is discharging, Required undock=true
|
||||
execute_discharging="Battery power save -ba"
|
||||
#? Command/script to execute when battery is charging, Required undock=true
|
||||
execute_charging="Battery power reset"
|
||||
|
||||
@@ -36,7 +36,7 @@ if [ ! -f $HOME/cache/.initial_startup_done ]; then
|
||||
grep 'kb_layout=' "$HOME/.config/hypr/UserConfigs/UserSettings.conf" | cut -d '=' -f 2 | cut -d ',' -f 1 2>/dev/null > $HOME/.cache/kb_layout
|
||||
|
||||
# Refreshing waybar, dunst, rofi etc.
|
||||
$RunCMD reloadall > /dev/null 2>&1 &
|
||||
$RunCMD reload_all > /dev/null 2>&1 &
|
||||
|
||||
# Create a marker file to indicate that the script has been executed.
|
||||
touch $HOME/.cache/.initial_startup_done
|
||||
|
||||
@@ -1,269 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
batterynotify_conf=$HOME/.config/hypr/configs/batterynotify.conf
|
||||
config_info() {
|
||||
cat << EOF
|
||||
|
||||
Edit $batterynotify_conf for options.
|
||||
|
||||
STATUS THRESHOLD INTERVAL
|
||||
Full $battery_full_threshold $notify Minutes
|
||||
Critical $battery_critical_threshold $timer Seconds then '$execute_critical'
|
||||
Low $battery_low_threshold $interval Percent then '$execute_low'
|
||||
Unplug $unplug_charger_threshold $interval Percent then '$execute_unplug'
|
||||
|
||||
Charging: $execute_charging
|
||||
Discharging: $execute_discharging
|
||||
EOF
|
||||
}
|
||||
|
||||
is_laptop() { # Check if the system is a laptop
|
||||
if grep -q "Battery" /sys/class/power_supply/BAT*/type; then
|
||||
return 0 # It's a laptop
|
||||
else
|
||||
echo "Cannot Detect a Battery. If this seems an error please report an issue to https://github.com/prasanthrangan/hyprdots."
|
||||
exit 0 # It's not a laptop
|
||||
fi
|
||||
}
|
||||
fn_verbose () {
|
||||
if $verbose; then
|
||||
cat << VERBOSE
|
||||
=============================================
|
||||
Battery Status: $battery_status
|
||||
Battery Percentage: $battery_percentage
|
||||
=============================================
|
||||
VERBOSE
|
||||
fi
|
||||
}
|
||||
fn_notify () { # Send notification
|
||||
|
||||
notify-send -a "Power" $1 -u $2 "$3" "$4" -p # Call the notify-send command with the provided arguments \$1 is the flags \$2 is the urgency \$3 is the title \$4 is the message
|
||||
}
|
||||
fn_percentage () {
|
||||
if [[ "$battery_percentage" -ge "$unplug_charger_threshold" ]] && [[ "$battery_status" != "Discharging" ]] && [[ "$battery_status" != "Full" ]] && (( (battery_percentage - last_notified_percentage) >= $interval )); then if $verbose; then echo "Prompt:UNPLUG: $battery_unplug_threshold $battery_status $battery_percentage" ; fi
|
||||
fn_notify "-t 2000 " "CRITICAL" "Battery Charged" "Battery is at $battery_percentage%. You can unplug the charger!"
|
||||
last_notified_percentage=$battery_percentage
|
||||
elif [[ "$battery_percentage" -le "$battery_critical_threshold" ]]; then
|
||||
count=$(( timer > $mnt ? timer : $mnt )) # reset count
|
||||
while [ $count -gt 0 ] && [[ $battery_status == "Discharging"* ]]; do
|
||||
for battery in /sys/class/power_supply/BAT*; do battery_status=$(< "$battery/status") ; done
|
||||
if [[ $battery_status != "Discharging" ]] ; then break ; fi
|
||||
fn_notify "-t 2000 -r 69 " "CRITICAL" "Battery Critically Low" "$battery_percentage% is critically low. Device will execute $execute_critical in $((count/60)):$((count%60)) ."
|
||||
count=$((count-1))
|
||||
sleep 1
|
||||
done
|
||||
[ $count -eq 0 ] && fn_action
|
||||
elif [[ "$battery_percentage" -le "$battery_low_threshold" ]] && [[ "$battery_status" == "Discharging" ]] && (( (last_notified_percentage - battery_percentage) >= $interval )); then if $verbose; then echo "Prompt:LOW: $battery_low_threshold $battery_status $battery_percentage" ; fi
|
||||
fn_notify "-t 2000 " "CRITICAL" "Battery Low" "Battery is at $battery_percentage%. Connect the charger."
|
||||
last_notified_percentage=$battery_percentage
|
||||
fi
|
||||
}
|
||||
fn_action () { #handles the $execute_critical command #? This is special as it will try to execute always
|
||||
count=$(( timer > $mnt ? timer : $mnt )) # reset count
|
||||
nohup $execute_critical
|
||||
}
|
||||
|
||||
fn_status () {
|
||||
if [[ $battery_percentage -ge $battery_full_threshold ]] && [[ "$battery_status" != *"Discharging"* ]]; then echo "Full and $battery_status"
|
||||
battery_status="Full" ;fi
|
||||
case "$battery_status" in # Handle the power supply status
|
||||
"Discharging") if $verbose; then echo "Case:$battery_status Level: $battery_percentage" ;fi
|
||||
if [[ "$prev_status" != "Discharging" ]] || [[ "$prev_status" == "Full" ]] ; then
|
||||
prev_status=$battery_status
|
||||
urgency=$([[ $battery_percentage -le "$battery_low_threshold" ]] && echo "CRITICAL" || echo "NORMAL")
|
||||
fn_notify "-t 2000 -r 54321 " "$urgency" "Charger Plug OUT" "Battery is at $battery_percentage%."
|
||||
$execute_discharging
|
||||
fi
|
||||
fn_percentage
|
||||
;;
|
||||
"Not"*|"Charging") if $verbose; then echo "Case:$battery_status Level: $battery_percentage" ;fi
|
||||
if [[ "$prev_status" == "Discharging" ]] || [[ "$prev_status" == "Not"* ]] ; then
|
||||
prev_status=$battery_status
|
||||
count=$(( timer > $mnt ? timer : $mnt )) # reset count
|
||||
urgency=$([[ "$battery_percentage" -ge $unplug_charger_threshold ]] && echo "CRITICAL" || echo "NORMAL")
|
||||
fn_notify "-t 2000 -r 54321 " "$urgency" "Charger Plug In" "Battery is at $battery_percentage%."
|
||||
$execute_charging
|
||||
fi
|
||||
fn_percentage
|
||||
;;
|
||||
"Full") if $verbose; then echo "Case:$battery_status Level: $battery_percentage" ;fi
|
||||
if [[ $battery_status != "Discharging" ]]; then
|
||||
now=$(date +%s)
|
||||
if [[ "$prev_status" == *"harging"* ]] || ((now - lt >= $((notify*60)) )); then
|
||||
fn_notify "-t 2000 -r 54321" "CRITICAL" "Battery Full" "Please unplug your Charger"
|
||||
prev_status=$battery_status lt=$now
|
||||
$execute_charging
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ ! -f "/tmp/hyprdots.batterynotify.status.fallback.$battery_status-$$" ]]; then
|
||||
echo "Status: '==>> "$battery_status" <<==' Script on Fallback mode,Unknown power supply status.Please copy this line and raise an issue to the Github Repo.Also run 'ls /tmp/hyprdots.batterynotify' to see the list of lock files.*"
|
||||
touch "/tmp/hyprdots.batterynotify.status.fallback.$battery_status-$$"
|
||||
fi
|
||||
fn_percentage
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_battery_info() { #? Might change this if we can get an effective way to parse dbus.
|
||||
total_percentage=0 battery_count=0
|
||||
for battery in /sys/class/power_supply/BAT*; do
|
||||
battery_status=$(<"$battery/status") battery_percentage=$(<"$battery/capacity")
|
||||
total_percentage=$((total_percentage + battery_percentage))
|
||||
battery_count=$((battery_count + 1))
|
||||
done
|
||||
battery_percentage=$((total_percentage / battery_count)) #? For Multiple Battery
|
||||
}
|
||||
|
||||
fn_status_change () { # Handle when status changes
|
||||
get_battery_info
|
||||
# Add these two lines at the beginning of the function
|
||||
local executed_low=false
|
||||
local executed_unplug=false
|
||||
|
||||
|
||||
if [ "$battery_status" != "$last_battery_status" ] || [ "$battery_percentage" != "$last_battery_percentage" ]; then
|
||||
last_battery_status=$battery_status
|
||||
last_battery_percentage=$battery_percentage # Check if battery status or percentage has changed
|
||||
fn_verbose
|
||||
fn_percentage
|
||||
|
||||
if [[ "$battery_percentage" -le "$battery_low_threshold" ]] && ! $executed_low; then $execute_low
|
||||
executed_low=true executed_unplug=false
|
||||
fi
|
||||
if [[ "$battery_percentage" -ge "$unplug_charger_threshold" ]] && ! $executed_unplug; then $execute_unplug
|
||||
executed_unplug=true executed_low=false
|
||||
fi
|
||||
|
||||
if $undock; then fn_status echo yes ; fi
|
||||
fi
|
||||
}
|
||||
|
||||
resume_processes() { for pid in $pids ; do if [ "$pid" -ne "$current_pid" ] ; then kill -CONT $pid ; notify-send -a "Battery Notify" -t 2000 -r 9889 -u "CRITICAL" "Debugging ENDED, Resuming Regular Process" ; fi ; done }
|
||||
|
||||
main() { # Main function
|
||||
if is_laptop; then
|
||||
rm -fr /tmp/hyprdots.batterynotify* # Cleaning the lock file
|
||||
battery_full_threshold=${battery_full_threshold:-100}
|
||||
battery_critical_threshold=${battery_critical_threshold:-5}
|
||||
unplug_charger_threshold=${unplug_charger_threshold:-80}
|
||||
battery_low_threshold=${battery_low_threshold:-20}
|
||||
timer=${timer:-120}
|
||||
notify=${notify:-1140}
|
||||
interval=${interval:-5}
|
||||
execute_critical=${execute_critical:-"systemctl suspend"}
|
||||
execute_low=${execute_low:-}
|
||||
execute_unplug=${execute_unplug:-}
|
||||
|
||||
config_info
|
||||
if $verbose; then for line in "Verbose Mode is ON..." "" "" "" "" ; do echo $line ; done;
|
||||
current_pid=$$
|
||||
pids=$(pgrep -f "/bin/bash $HOME/.config/hypr/scripts/batterynotify.sh" )
|
||||
for pid in $pids ; do if [ "$pid" -ne $current_pid ] ;then kill -STOP "$pid" ;notify-send -a "Battery Notify" -t 2000 -r 9889 -u "CRITICAL" "Debugging STARTED, Pausing Regular Process" ;fi ; done ; trap resume_processes SIGINT ; fi
|
||||
get_battery_info # initiate the function
|
||||
last_notified_percentage=$battery_percentage
|
||||
prev_status=$battery_status
|
||||
|
||||
dbus-monitor --system "type='signal',interface='org.freedesktop.DBus.Properties',path='$(upower -e | grep battery)'" 2> /dev/null | while read -r battery_status_change; do fn_status_change ; done
|
||||
fi
|
||||
}
|
||||
|
||||
verbose=false undock=false
|
||||
if [ ! -f "$batterynotify_conf" ]; then
|
||||
mkdir -p "$(dirname "$batterynotify_conf")"
|
||||
touch "$batterynotify_conf"
|
||||
echo "[CREATED] $batterynotify_conf"
|
||||
echo "
|
||||
#? Full battery threshold (default: 100%)
|
||||
battery_full_threshold=100
|
||||
#? Critical battery threshold (default: 10%)
|
||||
battery_critical_threshold=10
|
||||
#? Low battery threshold (default: 20%)
|
||||
battery_low_threshold=20
|
||||
#? Unplug charger threshold (default: 80%)
|
||||
unplug_charger_threshold=80
|
||||
#? Countdown timer before executing execute_critical (default: 120 seconds)
|
||||
timer=120
|
||||
#? Notify interval for Battery Full Status (default: 1140 mins/ 1 day)
|
||||
notify=1140
|
||||
#? Notify interval on LOW and UNPLUG Status (default: 5%)
|
||||
interval=5
|
||||
#? Shows Battery Plug In/Out/Full Notification
|
||||
undock=false
|
||||
#? Command/script to execute at minimum unplug_charger_threshold
|
||||
execute_unplug=\"\"
|
||||
#? Command/script to execute at maximum battery_low_threshold
|
||||
execute_low=\"\"
|
||||
#? Command/script to execute if battery on critical threshold (default: systemctl suspend)
|
||||
execute_critical=\"systemctl suspend\"
|
||||
#? Command/script to execute when battery is discharging, Required undock=true
|
||||
execute_discharging=\"\"
|
||||
#? Command/script to execute when battery is charging, Required undock=true
|
||||
execute_charging=\"\"
|
||||
" > "$batterynotify_conf"
|
||||
fi
|
||||
|
||||
source "$batterynotify_conf"
|
||||
case "$1" in
|
||||
--modify)
|
||||
EDITOR="${EDITOR:-code}" #* Use VS Code as the default editor
|
||||
echo -e "[Editor]: $EDITOR \n To change editor, run 'export EDITOR=prefered-editor' \n[Modifying]: $batterynotify_conf \nPress Any Key if done editing"
|
||||
#kitty -o allow_remote_control=yes -o listen_on=unix:/tmp/mykitty $(which $EDITOR) "$batterynotify_conf" > /dev/null 2>&1 &
|
||||
kitty "$(which $EDITOR)" "$batterynotify_conf" > /dev/null 2>&1 &
|
||||
LAST_MD5SUM=$(md5sum "$batterynotify_conf")
|
||||
while true; do CURRENT_MD5SUM=$(md5sum "$batterynotify_conf")
|
||||
if [ "$CURRENT_MD5SUM" != "$LAST_MD5SUM" ]; then
|
||||
notify-send "Config Changed: Needs reboot or restart $0"
|
||||
LAST_MD5SUM="$CURRENT_MD5SUM"
|
||||
fi ; read -t 2 -n 1 > /dev/null && break #? loop every 2 seconds
|
||||
done
|
||||
exit 0
|
||||
;;
|
||||
--info)
|
||||
config_info
|
||||
exit 0
|
||||
;;
|
||||
--reset)
|
||||
rm -r "$batterynotify_conf"
|
||||
echo "[RESET] Batterynotify configuration"
|
||||
exit 0
|
||||
;;
|
||||
--verbose)
|
||||
verbose=true
|
||||
;;
|
||||
-h|--help)
|
||||
cat << HELP
|
||||
Usage: $0 [options]
|
||||
|
||||
[--modify] Modify configuration file
|
||||
[--info] Display configuration information
|
||||
[--reset] Reset configuration
|
||||
[--verbose] Debugging mode
|
||||
[-h|--help] This Message
|
||||
HELP
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
mnc=2 mxc=50 mnl=10 mxl=80 mnu=50 mxu=100 mnt=60 mxt=1000 mnf=80 mxf=100 mnn=1 mxn=1140 mni=1 mxi=10 #Defaults Ranges
|
||||
check_range() {
|
||||
local var=$1 min=$2 max=$3 error_message=$4
|
||||
if [[ $var =~ ^[0-9]+$ ]] && (( var >= min && var <= max )); then
|
||||
var=$var ; shift 2
|
||||
else
|
||||
echo "$1 ERROR: $error_message must be $min - $max." >&2 ; exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_range "$battery_full_threshold" $mnf $mxf "Full Threshold"
|
||||
check_range "$battery_critical_threshold" $mnc $mxc "Critical Threshold"
|
||||
check_range "$battery_low_threshold" $mnl $mxl "Low Threshold"
|
||||
check_range "$unplug_charger_threshold" $mnu $mxu "Unplug Threshold"
|
||||
check_range "$timer" $mnt $mxt "Timer"
|
||||
check_range "$notify" $mnn $mxn "Notify"
|
||||
check_range "$interval" $mni $mxi "Interval"
|
||||
|
||||
trap resume_processes SIGINT
|
||||
|
||||
main
|
||||
@@ -6,7 +6,7 @@ source "$CONFIG_FILE"
|
||||
|
||||
|
||||
# Toggle touchpad state. (SUPER SHIFT D)
|
||||
touchpad() {
|
||||
toggle_touchpad() {
|
||||
local status_file="$STATUS_FILE"
|
||||
local action
|
||||
|
||||
@@ -24,7 +24,7 @@ touchpad() {
|
||||
|
||||
|
||||
# Toggle Wifi
|
||||
wifi() {
|
||||
toggle_wifi() {
|
||||
wifi_status=$(nmcli radio wifi)
|
||||
if [ "$wifi_status" == "enabled" ]; then
|
||||
nmcli radio wifi off
|
||||
|
||||
@@ -7,6 +7,7 @@ STATUS_FILE="$DIR/touchpad.status"
|
||||
|
||||
# For Notification icon
|
||||
notif="$HOME/.config/swaync/images/bell.png"
|
||||
iDIR="$HOME/.config/swaync/icons"
|
||||
|
||||
# Scripts DIR
|
||||
SCRIPTSDIR="$HOME/.config/hypr/scripts"
|
||||
@@ -64,5 +65,4 @@ NOTES_AUTHOR="$(whoami)"
|
||||
NOTES_FOLDER="$HOME/Documents/Notes"
|
||||
NOTES_EDITOR="kitty --class fly_is_kitty -e nvim"
|
||||
|
||||
# Misc
|
||||
lock="$SCRIPTSDIR/device_cmd.sh lockscreen"
|
||||
|
||||
@@ -188,7 +188,7 @@ edit() {
|
||||
}
|
||||
main() {
|
||||
options=("ENVariables.conf" "WindowRules.conf" "Startup_Apps.conf" "UserKeybinds.conf" "Monitors.conf" "Laptops.conf" "UserSettings.conf" "Settings.conf" "Keybinds.conf")
|
||||
choice=$(menu | rofi -dmenu -i -l 9 -p " View / Edit Hyprland Configs:" | cut -d. -f1)
|
||||
choice=$(menu | rofi -dmenu -i -p " View / Edit Hyprland Configs:" | cut -d. -f1)
|
||||
[[ $choice =~ ^[1-9]$ ]] && kitty -e nano "$UserConfigs/${options[choice - 1]}"
|
||||
}
|
||||
main
|
||||
|
||||
@@ -33,7 +33,7 @@ sys_poweroff() {
|
||||
}
|
||||
|
||||
# Reload Waybar, Rofi, Swaync, and Rainbowborder.sh (SHIFT ALT R)
|
||||
reloadall() {
|
||||
reload_all() {
|
||||
file_exists() {
|
||||
[ -e "$1" ]
|
||||
}
|
||||
@@ -86,8 +86,6 @@ lock_screen() {
|
||||
|
||||
# Volume Controller
|
||||
volume() {
|
||||
iDIR="$HOME/.config/swaync/icons"
|
||||
|
||||
get_volume() {
|
||||
volume=$(pamixer --get-volume)
|
||||
if [[ "$volume" -eq "0" ]]; then
|
||||
@@ -212,7 +210,6 @@ volume() {
|
||||
|
||||
# ScreenShot
|
||||
screenshot() {
|
||||
iDIR="$HOME/.config/swaync/icons"
|
||||
notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/picture.png"
|
||||
time=$(date "+%d-%b_%H-%M-%S")
|
||||
dir="$(xdg-user-dir)/Pictures/Screenshots"
|
||||
@@ -275,8 +272,6 @@ screenshot() {
|
||||
|
||||
# Brightness Controller
|
||||
brightness() {
|
||||
|
||||
iDIR="$HOME/.config/swaync/icons"
|
||||
notification_timeout=1000
|
||||
|
||||
get_backlight() {
|
||||
@@ -333,3 +328,50 @@ case "$1" in
|
||||
esac
|
||||
}
|
||||
|
||||
battery_notify() {
|
||||
last="NONE" # Possible values: NONE, FULL, LOW, CRITICAL, CHARGING
|
||||
# Default values for LOW/CRITICAL status
|
||||
low=40
|
||||
critical=20
|
||||
|
||||
while true; do
|
||||
# If battery is plugged, do stuff
|
||||
battery="/sys/class/power_supply/BAT0"
|
||||
if [ -d $battery ]; then
|
||||
capacity=$(cat $battery/capacity)
|
||||
status=$(cat $battery/status)
|
||||
|
||||
# If battery full and not already warned about that
|
||||
if [ "$last" != "FULL" ] && [ "$status" = "Full" ]; then
|
||||
notify-send -u normal -i "$iDIR/battery-full.png" "Battery full" "Remove the adapter! $capacity%"
|
||||
last="FULL"
|
||||
fi
|
||||
|
||||
# If low and discharging
|
||||
if [ "$last" != "LOW" ] && [ "$status" = "Discharging" ] && [ $capacity -le $low ]; then
|
||||
notify-send -u normal -i "$iDIR/battery-low.png" "Battery low" "Plug in the adapter! $capacity%"
|
||||
last="LOW"
|
||||
fi
|
||||
|
||||
# If critical and discharging
|
||||
if [ "$status" = "Discharging" ] && [ $capacity -le $critical ]; then
|
||||
notify-send -u critical -i "$iDIR/battery-low.png" "Battery very low" "Plug in the adapter!!! $capacity%"
|
||||
last="CRITICAL"
|
||||
fi
|
||||
|
||||
# If charging and not already notified
|
||||
if [ "$last" != "CHARGING" ] && [ "$status" = "Charging" ]; then
|
||||
notify-send -u low -i "$iDIR/battery-charging.png" "Charger connected" "Battery is charging $capacity%"
|
||||
last="CHARGING"
|
||||
fi
|
||||
|
||||
# If unplugged and not already notified
|
||||
if [ "$last" != "UNPLUGGED" ] && [ "$status" = "Discharging" ] && [ "$capacity" != "Full" ]; then
|
||||
notify-send -u normal -i "$iDIR/battery-notcharging.png" "Charger unplugged" "Battery is not charging! $capacity%"
|
||||
last="UNPLUGGED"
|
||||
fi
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ source "$CONFIG_FILE"
|
||||
|
||||
|
||||
# Change blur (SUPER SHIFT Q)
|
||||
blur (){
|
||||
toggle_blur (){
|
||||
STATE=$(hyprctl -j getoption decoration:blur:passes | jq ".int")
|
||||
|
||||
if [ "${STATE}" == "2" ]; then
|
||||
@@ -20,7 +20,7 @@ blur (){
|
||||
fi
|
||||
}
|
||||
|
||||
animation() {
|
||||
toggle_animation() {
|
||||
STATE=$(hyprctl -j getoption animations:enabled | jq ".int")
|
||||
if [ "${STATE}" = "1" ]; then
|
||||
hyprctl keyword animations:enabled 0
|
||||
@@ -32,7 +32,7 @@ animation() {
|
||||
|
||||
}
|
||||
|
||||
rainbowborder() {
|
||||
rainbow_border() {
|
||||
function random_hex() {
|
||||
random_hex=("0xff$(openssl rand -hex 3)")
|
||||
echo $random_hex
|
||||
@@ -44,7 +44,7 @@ hyprctl keyword general:col.inactive_border $(random_hex) $(random_hex) $(random
|
||||
}
|
||||
|
||||
# Change layout to master & dwindle (SUPER SPACE)
|
||||
layout() {
|
||||
change_layout() {
|
||||
LAYOUT=$(hyprctl -j getoption general:layout | jq -r '.str')
|
||||
|
||||
case $LAYOUT in
|
||||
@@ -73,7 +73,7 @@ layout() {
|
||||
|
||||
# Script for Random Wallpaper ( SHIFT ALT W)
|
||||
|
||||
randomwall() {
|
||||
random_wall() {
|
||||
swww query || swww init
|
||||
PICS=("${wallDIR}"/*.{jpg,jpeg,png,gif}) # Array of image files in wallDIR
|
||||
|
||||
@@ -89,7 +89,7 @@ randomwall() {
|
||||
|
||||
# Change Wallpaper automatically after 30min
|
||||
|
||||
autowall() {
|
||||
auto_wall() {
|
||||
INTERVAL=1800 # This controls (in seconds) when to switch to the next image
|
||||
|
||||
while true; do
|
||||
@@ -104,7 +104,7 @@ autowall() {
|
||||
|
||||
|
||||
# selecting wallpapers (SUPER W)
|
||||
selectwall() {
|
||||
select_wall() {
|
||||
build_theme() {
|
||||
rows="$1"
|
||||
cols="$1"
|
||||
@@ -132,7 +132,7 @@ selectwall() {
|
||||
}
|
||||
|
||||
# Waybar Layout (ALT W)
|
||||
waybarl() {
|
||||
waybar_layout() {
|
||||
menu() {
|
||||
find "$config_dir" -maxdepth 1 -type f -exec basename {} \; | sort
|
||||
}
|
||||
@@ -193,7 +193,7 @@ notify-send "Hello" "${name}?,you're back? welcome what will we do today!"
|
||||
}
|
||||
|
||||
# Switch Keyboard Layout (ALT F1)
|
||||
kb() {
|
||||
kb_changer() {
|
||||
if [ ! -f "$layout_f" ]; then
|
||||
default_layout=$(grep 'kb_layout=' "$settings_file" | cut -d '=' -f 2 | cut -d ',' -f 1 2>/dev/null)
|
||||
if [ -z "$default_layout" ]; then
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Directory for icons
|
||||
iDIR="$HOME/.config/swaync/icons"
|
||||
scriptsDir="$HOME/.config/hypr/scripts"
|
||||
RunCMD="$scriptsDir/RunCMD.sh"
|
||||
# Source the configuration file.
|
||||
CONFIG_FILE=~/.config/hypr/scripts/Ref.sh
|
||||
source "$CONFIG_FILE"
|
||||
|
||||
# Note: You can add more options below with the following format:
|
||||
# ["TITLE"]="link"
|
||||
|
||||
@@ -13,22 +13,22 @@ declare -A menu_options=(
|
||||
|
||||
#waybar
|
||||
["wbt ToggleWaybar"]="killall -SIGUSR1 waybar"
|
||||
["wbl WaybarLayout"]="$RunCMD waybarl"
|
||||
["wbl WaybarLayout"]="$RunCMD waybar_layout"
|
||||
["wbr Reload Waybar"]="$RunCMD reload_waybar"
|
||||
["wbu Update Waybar"]="$RunCMD update_waybar"
|
||||
#hypr
|
||||
["hpr Reload hyprland"]="$RunCMD reload_hypr"
|
||||
["rld Reload All"]="$RunCMD reloadall"
|
||||
["cl ChangeLayout"]="$RunCMD layout"
|
||||
["rld Reload All"]="$RunCMD reload_all"
|
||||
["cl ChangeLayout"]="$RunCMD change_layout"
|
||||
["gm GameMode"]="$RunCMD gamemode"
|
||||
["bl ChangeBlur"]="$RunCMD blur"
|
||||
["bl ChangeBlur"]="$RunCMD toggle_blur"
|
||||
["flt Float all window"]="hyprctl dispatch workspaceopt allfloat"
|
||||
["hpa Toggle hyprland animation"]="$RunCMD animation"
|
||||
["hpa Toggle hyprland animation"]="$RunCMD toggle_animation"
|
||||
["op1 enable_opaque"]="$RunCMD enable_opaque"
|
||||
["op0 disable_opaque"]="$RunCMD disable_opaque"
|
||||
#wallpaper
|
||||
["ws Wallpaper Select"]="$RunCMD selectwall"
|
||||
["wc Random Wallpaper"]="$RunCMD randomwall"
|
||||
["ws Wallpaper Select"]="$RunCMD select_wall"
|
||||
["wc Random Wallpaper"]="$RunCMD random_wall"
|
||||
#RunCMD
|
||||
["; Launcher"]="rofi -show drun -modi drun,filebrowser,run,window -theme $HOME/.config/rofi/launcher.rasi"
|
||||
["cb Clipboard"]="$RunCMD clip"
|
||||
@@ -47,9 +47,9 @@ declare -A menu_options=(
|
||||
["cn Close Notifactions"]="swaync-client -C"
|
||||
["dm0"]="$RunCMD enable_edp1"
|
||||
["dm1"]="$RunCMD enable_edp1"
|
||||
["tt Touchpad"]="$RunCMD touchpad"
|
||||
["tw Wifi"]="$RunCMD wifi"
|
||||
["kb Keyboard switcher"]="$RunCMD kb"
|
||||
["tt Touchpad"]="$RunCMD toggle_touchpad"
|
||||
["tw Wifi"]="$RunCMD toggle_wifi"
|
||||
["kb Keyboard switcher"]="$RunCMD kb_changer"
|
||||
#Misc
|
||||
["ff Firefox"]="firefox"
|
||||
["sr ScreenRecord"]="$RunCMD sr"
|
||||
|
||||
Reference in new issue
Block a user