diff --git a/README.md b/README.md
index d3f11e90..a9dbe875 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,6 @@ cd misc
cp -r fonts ~/.local/
cp .zshenv ~/
cp -r bin ~/.local/
-cp -r Notes ~/Documents
chmod +x ~/.config/hypr/scripts/*
chmod +x ~/.config/hypr/UserScripts/*
diff --git a/config/hypr/scripts/BatteryNotify.sh b/config/hypr/scripts/BatteryNotify.sh
index 3ea7326f..c458601f 100755
--- a/config/hypr/scripts/BatteryNotify.sh
+++ b/config/hypr/scripts/BatteryNotify.sh
@@ -1,41 +1,22 @@
#!/bin/bash
-# Prasanthrangan Work
+batterynotify_conf=$HOME/.config/hypr/scripts/batterynotify.conf
+config_info() {
+cat << EOF
-trap resume_processes SIGINT
-in_range() { local num=$1 local min=$2 local max=$3 ; [[ $num =~ ^[0-9]+$ ]] && (( num >= min && num <= max )); }
-mnc=5 mxc=80 mnl=20 mxl=50 mnu=80 mxu=100 mnt=60 mxt=1000 mnf=80 mxf=100 mnn=1 mxn=60 mni=1 mxi=10 verbose=false undock=false #Defaults Ranges
-while (( "$#" )); do # Parse command-line arguments and defaults
- case "$1" in
-"--full"|"-f") if in_range "$2" $mnf $mxf; then battery_full_threshold=$2 ; shift 2 ; else echo "$1 Error: Full Threshold must be $mnf - $mxf." >&2 ; exit 1 ; fi;;
-"--critical"|"-c") if in_range "$2" $mnc $mxc; then battery_critical_threshold=$2 ; shift 2 ; else echo "$1 ERROR: Critical Threshold must be $mnc - $mxc." >&2 ; exit 1 ; fi;;
-"--low"|"-l") if in_range "$2" $mnl $mnu; then battery_low_threshold=$2 ; shift 2 ; else echo "$1 ERROR: Low Threshold $mnl - $mnu." >&2 ; exit 1 ; fi;;
-"--unplug"|"-u") if in_range "$2" $mnu $mxu; then unplug_charger_threshold=$2 ; shift 2 ; else echo "$1 ERROR: Unplug Threshold must be $mnu $mxu." >&2 ; exit 1 ; fi;;
-"--timer"|"-t") if in_range "$2" $mnt $mxt; then timer=$2 ; shift 2 ; else echo "$1 ERROR: Timer must be $mnt - $mxt." >&2 ; exit 1 ; fi;;
-"--notify"|"-n") if in_range "$2" $mnn $mxn; then notify=$2 ; shift 2 ; else echo "$1 ERROR: Notify must be $mnn - $mxn in minutes." >&2 ; exit 1 ; fi;;
-"--interval"|"-i") if in_range "$2" $mni $mxi; then interval=$2 ; shift 2 ; else echo "$1 ERROR: Interval must be by $mni% - $mxi% intervals." >&2 ; exit 1 ; fi;;
-"--verbose"|"-v") verbose=true ; shift ;;
-"--undock"|"on") undock=true ; shift ;;
-"--execute"|"-e") execute=$2 ; shift 2 ;;
+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
+}
- *|"--help"|"-h")
- echo "Usage: $0 [options]"
- echo " --verbose, -v Verbose Mode"
- echo " --undock, on Shows Battery Plug In/Out/Full Notification"
- echo " --full, -f Set battery full threshold (default: 100% percent)"
- echo " --critical, -c Set battery critical threshold (default: 10% percent)"
- echo " --low, -l Set battery low threshold (default: 20% percent)"
- echo " --unplug, -u Set unplug charger threshold (default: 80% percent )"
- echo " --timer, -t Set countdown timer (default: 120 seconds)"
- echo " --interval, -i Set notify interval on LOW UNPLUG Status (default: 5% percent)"
- echo " --notify, -n Set notify interval for Battery Full Status (default: 1140 mins/ 1 day)"
- echo " --execute, -e Set command/script to execute if battery on critical threshold (default: systemctl suspend)"
- echo " --help, -h Show this help message
- Visit https://github.com/prasanthrangan/hyprdots for the Github Repo"
- exit 0
- ;;
- esac
-done
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
@@ -51,8 +32,6 @@ cat << VERBOSE
Battery Status: $battery_status
Battery Percentage: $battery_percentage
=============================================
-
-
VERBOSE
fi
}
@@ -69,7 +48,7 @@ fn_percentage () {
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 5000 -r 69 " "CRITICAL" "Battery Critically Low" "$battery_percentage% is critically low. Device will execute $execute in $((count/60)):$((count%60)) ."
+ fn_notify "-t 5000 -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
@@ -79,13 +58,13 @@ fn_percentage () {
last_notified_percentage=$battery_percentage
fi
}
-fn_action () { #handles the $execute command
+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
+ nohup $execute_critical
}
fn_status () {
-if [[ $battery_percentage -ge $battery_full_threshold ]] && [ "$battery_status" == *"Charging"* ]; then echo "Full and $battery_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
@@ -93,32 +72,27 @@ case "$battery_status" in # Handle the power supply status
prev_status=$battery_status
urgency=$([[ $battery_percentage -le "$battery_low_threshold" ]] && echo "CRITICAL" || echo "NORMAL")
fn_notify "-t 5000 -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
- # Due to modifications of some devices Not Charging after reaching 99 or limits
- #if [[ ! -f "/tmp/hyprdots.batterynotify.status.$battery_status-$$" ]] && [[ "$battery_status" == "Not"* ]] ; then
- #touch "/tmp/hyprdots.batterynotify.status.$battery_status-$$"
- #count=$(( timer > $mnt ? timer : $mnt )) # reset count
- #echo "Status: '==>> "$battery_status" <<==' Device Reports Not Charging!,This may be device Specific errors."
- #fn_notify "-t 5000 " "CRITICAL" "Charger Plug In" "Battery is at $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 5000 -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 5000 -r 54321" "CRITICAL" "Battery Full" "Please unplug your Charger"
prev_status=$battery_status lt=$now
+ $execute_charging
fi
fi
;;
@@ -132,49 +106,164 @@ case "$battery_status" in # Handle the power supply status
esac
}
-fn_status_change () { # Handle when status changes
-for battery in /sys/class/power_supply/BAT*; do battery_status=$(< "$battery/status") battery_percentage=$(< "$battery/capacity")
- 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 $undock; then fn_status echo yes ; fi
-fi
-done
+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
}
-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 }
+
+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:-10}
+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:-}
-execute=${execute:-"systemctl suspend"}
-cat << EOF
-Script is running...
-Check $0 --help for options.
-
- STATUS THRESHOLD INTERVAL
- Full $battery_full_threshold $notify Minutes
- Critical $battery_critical_threshold $timer Seconds then "$execute"
- Low $battery_low_threshold $interval Percent
- Unplug $unplug_charger_threshold $interval Percent
-
-
-EOF
+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
- fn_status_change # initiate the function
+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
diff --git a/config/hypr/scripts/batterynotify.conf b/config/hypr/scripts/batterynotify.conf
new file mode 100644
index 00000000..a2362d1c
--- /dev/null
+++ b/config/hypr/scripts/batterynotify.conf
@@ -0,0 +1,28 @@
+
+ #? 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="Power_Manager.sh save -ba"
+ #? Command/script to execute when battery is charging, Required undock=true
+execute_charging="Power_Manager reset"
+
diff --git a/misc/Notes/Templates/LaTeX.tex b/misc/Notes/Templates/LaTeX.tex
deleted file mode 100644
index 0facc95c..00000000
--- a/misc/Notes/Templates/LaTeX.tex
+++ /dev/null
@@ -1,41 +0,0 @@
-\documentclass[letterpaper, 10pt]{report}
-
-%
-\usepackage[T1]{fontenc}
-\usepackage{hyperref, newpxmath, lipsum}
-\usepackage{tgtermes}
-\usepackage{xcolor, tikz, tcolorbox, setspace}
-\usepackage{fontspec, fancyhdr, fancyvrb, lastpage, geometry, graphicx}
-\usepackage[Glenn]{fncychap}
-%
-
-%
-\hypersetup{
- colorlinks=true,
- linkcolor=blue,
- urlcolor=red,
-}
-\onehalfspacing
-\pagestyle{fancy}
-\rhead{\thepage}
-\cfoot{Page \thepage\ of the \pageref{LastPage}}
-\setmainfont{Arial}
-%
-
-%
-\title{}
-\author{}
-%
-
-\begin{document}
-\maketitle
-% \tableofcontents
-% \pagebreak
-\thispagestyle{fancy}
-%
-
-
-
-
-%
-\end{document}
diff --git a/misc/Notes/Templates/Presentation.tex b/misc/Notes/Templates/Presentation.tex
deleted file mode 100644
index 4a02f1a5..00000000
--- a/misc/Notes/Templates/Presentation.tex
+++ /dev/null
@@ -1,40 +0,0 @@
-\documentclass{beamer}
-
-%
-\usepackage[T1]{fontenc}
-\usepackage{hyperref, newpxmath, lipsum}
-\usepackage{tgtermes}
-\usepackage{xcolor, tikz, tcolorbox, setspace}
-\usepackage{fontspec, lastpage, geometry, graphicx}
-%
-
-%
-\hypersetup{
- colorlinks=true,
- linkcolor=blue,
- urlcolor=red,
-}
-\setmainfont{Arial}
-\usetheme{Frankfurt}
-%
-
-%
-\title{}
-\author{}
-%
-
-\begin{document}
-\maketitle
-% \tableofcontents
-%
-
-\begin{frame}
-\frametitle{}
-
-
-\end{frame}
-
-
-
-%
-\end{document}
diff --git a/misc/Notes/Templates/RMarkdown.rmd b/misc/Notes/Templates/RMarkdown.rmd
deleted file mode 100644
index 65950c58..00000000
--- a/misc/Notes/Templates/RMarkdown.rmd
+++ /dev/null
@@ -1,43 +0,0 @@
----
-output:
- pdf_document:
- latex_engine: xelatex
-header-includes:
- - \usepackage{bbm}
- - \usepackage[T1]{fontenc}
- - \usepackage{fontspec}
- - \usepackage[onehalfspacing]{setspace}
- - \usepackage{xcolor}
- - \usepackage{cite}
- - \usepackage{booktabs}
- - \usepackage{lipsum}
- - \usepackage{multicol}
- - \usepackage{lastpage}
- - \usepackage{hyperref}
- - \usepackage{fancyhdr}
----
-\setlength{\headheight}{52pt}
-\definecolor{Blue}{RGB}{5, 88, 255}
-\setmainfont{Source Code Pro}
-
-\title{\textbf{{\color{Blue}TITLE}}}
-\author{\textit{}}
-\date{}
-
-\thispagestyle{empty}
-\setcounter{page}{0}
-\clearpage
-\maketitle
-\thispagestyle{empty}
-\pagestyle{fancy}
-\fancyhf{}
-\lhead{\thepage}
-\rhead{}
-\renewcommand{\plainheadrulewidth}{0pt}
-\rule{\textwidth}{1pt}
-\tableofcontents
-\rule{\textwidth}{1pt}
-\pagebreak
-
-\section{Introduction}
-
diff --git a/misc/Notes/Templates/SimpleNote.md b/misc/Notes/Templates/SimpleNote.md
deleted file mode 100644
index ccb5f77a..00000000
--- a/misc/Notes/Templates/SimpleNote.md
+++ /dev/null
@@ -1,4 +0,0 @@
----
-author:
----
-
diff --git a/misc/Notes/Templates/main_options.md b/misc/Notes/Templates/main_options.md
deleted file mode 100644
index 64ebd089..00000000
--- a/misc/Notes/Templates/main_options.md
+++ /dev/null
@@ -1,3 +0,0 @@
-Create a new note
-View notes
-Delete a note
diff --git a/misc/Notes/Templates/temp_options.md b/misc/Notes/Templates/temp_options.md
deleted file mode 100644
index 2a36cd57..00000000
--- a/misc/Notes/Templates/temp_options.md
+++ /dev/null
@@ -1,4 +0,0 @@
-Basic
-LaTeX
-RMark
-Beamer
diff --git a/misc/bin/Power_Manager b/misc/bin/Power_Manager
new file mode 100755
index 00000000..51478d75
--- /dev/null
+++ b/misc/bin/Power_Manager
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+# Configuration files
+ConfDir="$HOME/.config"
+hyprlandConf="$ConfDir/hypr/hyprland.conf"
+windowRules="$ConfDir/hypr/UserConfigs/WindowRules.conf"
+animFile="$ConfDir/hypr/UserConfigs/UserSettings.conf"
+PowManFile="$HOME/.cache/PowerManager.conf"
+
+# Command-line option
+powerOpt="$1"; shift
+
+# Function to append a line to PowerManager.conf
+append() {
+ grep -q "$1" "$PowManFile" || { echo "$1" >> "$PowManFile"; echo "$2"; }
+}
+
+# Function to remove a line from PowerManager.conf
+remove() {
+ grep -q "$1" "$PowManFile" && { sed -i "/$1/d" "$PowManFile"; echo "$2"; }
+}
+
+# Ensure PowerManager.conf is sourced in hyprland.conf
+source_files() {
+ [[ ! -f $PowManFile ]] && { touch $PowManFile && echo "Added: $hyprlandConf"; }
+ grep -q "source = $PowManFile" "$hyprlandConf" || { echo "source = $PowManFile #! This File is modified by Power_Manager options(To remove: 'Power_Manager reset')" >> "$hyprlandConf"; }
+}
+
+# Print help message
+print_help() {
+ echo "Usage: PowerManager $powerOpt [options]"
+ sed -n "/^$powerOpt() {/,/^}/p" "$0" | sed -n '/case/,/esac/p' | grep ') #?' | awk '{gsub(/^[ \t]+/, ""); gsub(/\)/, "]"); gsub(/\|/, "] ["); print}' | awk '{print "["$0}' | awk -F '#?' '{sub("\\?", "", $2); printf "%-30s %s\n", $1, $2}'
+}
+
+# Reset power-related settings
+reset() {
+ : > "$PowManFile"
+ grep -q "source = $PowManFile" "$hyprlandConf" && { sed -i "\#source = $PowManFile#d" "$hyprlandConf"; }
+ sed -i 's/^\s*#!\(.*windowrule.*opacity\)/\1/' "$windowRules"
+ sed -i 's/\(animation = borderangle,\) 0,/\1 1,/' "$animFile"
+ hyprctl reload
+}
+
+# Save power-related settings based on command-line options
+save() {
+ [[ -z "$@" ]] && { print_help; }
+ source_files
+ declare -A processed_flags
+ for arg in "$@"; do
+ if [ "${processed_flags[$arg]}" != "true" ]; then
+ case $arg in
+ -a|--animations) append "animations:enabled = 0" "DISABLE Animations" ;;
+ -ba|--borderangle) append "animation = borderangle, 0" "DISABLE Border angle animation" ;;
+ -b|--blur) append "decoration:blur:enabled = 0" "DISABLE Blur" ;;
+ -o|--opacity)
+ if grep -q '^[^#]*windowrule.*opacity' "$windowRules"; then
+ sed -i '/^[^#]*windowrule.*opacity/s/^/#!/' "$windowRules" && echo "DISABLE Transparent opacity"
+ fi
+ ;;
+ *) echo "Unknown flag: $arg"; print_help; exit 1 ;;
+ esac
+ processed_flags[$arg]="true"
+ fi
+ done
+}
+
+# Unset (revert) power-related settings based on command-line options
+unset() {
+ [[ -z "$@" ]] && { print_help; }
+ source_files
+ declare -A processed_flags
+ for arg in "$@"; do
+ if [ "${processed_flags[$arg]}" != "true" ]; then
+ case $arg in
+ -a|--animations) remove "animations:enabled = 0" "ENABLE Animations" ;;
+ -ba|--borderangle)
+ remove "animation = borderangle, 0" "ENABLE Border angle animation"
+ sed -i 's/\(animation = borderangle,\) 0,/\1 1,/' "$animFile"
+ ;;
+ -b|--blur) remove "decoration:blur:enabled = 0" "ENABLE Blur" ;;
+ -o|--opacity) sed -i 's/^\s*#!\(.*windowrule.*opacity\)/\1/' "$windowRules" ;;
+ *) echo "Unknown flag: $arg"; print_help; exit 1 ;;
+ esac
+ processed_flags[$arg]="true"
+ fi
+ done
+ hyprctl reload
+}
+
+# Placeholder function for handling power-saving options
+max() {
+ echo "Placeholder function for handling power-saving options"
+}
+
+# Execute the selected function based on the provided command-line option
+$powerOpt "$@"
diff --git a/misc/bin/notes b/misc/bin/notes
deleted file mode 100755
index a3e10d83..00000000
--- a/misc/bin/notes
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/bin/sh
-
-# <<--------- Settings --------->> #
-
-# Set the directory where the notes are stored
-NOTES_DIR="$HOME/Documents/Notes"
-# Set the editor to use
-EDITOR="nvim"
-# Set the file extension for the notes
-EXTENSION="*"
-
-# <<--------- Choosing Templates --------->> #
-Basic() {
-
- notify-send "Basic Document Created!"
- cd $NOTES_DIR
- cp $NOTES_DIR/Templates/SimpleNote.md $NOTES_DIR/"$note_name.md"
- nvim $NOTES_DIR/"$note_name.md"
-}
-
-LaTeX() {
-
- notify-send "LaTeX Document Created!"
- cd $NOTES_DIR
- cp $NOTES_DIR/Templates/LaTeX.tex $NOTES_DIR/"$note_name.tex"
- nvim $NOTES_DIR/"$note_name.tex"
-}
-
-Presentation() {
-
- notify-send "Beamer Presentation Created!"
- cd $NOTES_DIR
- cp $NOTES_DIR/Templates/Presentation.tex $NOTES_DIR/"$note_name.tex"
- nvim $NOTES_DIR/"$note_name.tex"
-}
-
-RMark() {
-
- notify-send "R Markdown Document Created!"
- cd $NOTES_DIR
- cp $NOTES_DIR/Templates/RMarkdown.rmd $NOTES_DIR/"$note_name.rmd"
- nvim $NOTES_DIR/"$note_name.rmd"
-}
-
-template() {
-
- echo "1. Basic"
- echo "2. LaTeX"
- echo "3. R Markdown"
- echo "4. Presentation"
- read -p "Enter your choice: " TYPE
- case $TYPE in
- 1) Basic ;;
- 2) LaTeX ;;
- 3) RMark ;;
- 4) Presentation ;;
- *) echo "Invalid!" ;;
- esac
-}
-
-# <<--------- Functions --------->> #
-create_note() {
-
- read -p "Enter the name of the note: " "note_name"
- if [ -f $NOTES_DIR/$note_name.$EXTENSION ]; then
- echo "Note already exists"
- echo "1. Overwrite"
- echo "2. Cancel"
- read -p "Enter your choice: " choice
- case $choice in
- 1) notify-send "New Note Created!" &&
- nvim $NOTES_DIR/$note_name.$EXTENSION ;;
- 2) main ;;
- *) echo "Invalid choice" ;;
- esac
- else
- template
- fi
-}
-
-view_note() {
-
- note=$(find $NOTES_DIR -type f -name "*.$EXTENSION" | fzf --preview 'bat --color=always {}')
- if [ -z "$note" ]; then
- exit
- else
- nvim "$note"
- view_note
- fi
-}
-
-delete_note() {
-
- note=$(find $NOTES_DIR -type f -name "*.$EXTENSION" | fzf --preview 'bat --color=always {}')
- if [ -z "$note" ]; then
- main
- else
- rm $note
- echo "Note Removed!"
- fi
-}
-
-# <<--------- Main --------->> #
-
-main() {
-
- # Check if the note directory exists
- if [ ! -d $NOTES_DIR ]; then
- mkdir $NOTES_DIR
- fi
-
- # Check if the note directory is empty
- if [ ! "$(ls -A $NOTES_DIR)" ]; then
- echo "No notes found"
- echo "Creating a new note"
- create_note
- else
- echo "Notes found"
- echo "1. Create a new note"
- echo "2. View a note"
- echo "3. Delete a note"
- echo "4. Exit"
- read -p "Enter your choice: " choice
-
- case $choice in
- 1) create_note ;;
- 2) view_note ;;
- 3) delete_note ;;
- 4) exit 0 ;;
- *) echo "Invalid choice" ;;
- esac
- fi
-}
-
-# <<--------- Arguments --------->> #
-if [ "$1" = "view" ]; then
- view_note
-else
- main
-fi
\ No newline at end of file