feat(scripts): Removed Scripts which I don't use.

This commit is contained in:
sankalp committed 2024-02-10 16:32:08 +05:45
1 parent 72b6efc817
commit a05fbd8b2d
8 files changed
+303 -361

No files matched your search

+75 -48
View File
@@ -1,6 +1,11 @@
#!/bin/bash
source ~/.config/hypr/scripts/Ref.sh
######################################
# #
# Rofi Option for Xmenu #
# #
######################################
_confirm_rofi() {
rofi -theme-str 'window {location: center; anchor: center; fullscreen: false; width: 250px;}' \
@@ -21,6 +26,13 @@ _need_confirm() {
return 1
fi
}
######################################
# #
# Power & Reboot #
# #
######################################
sys_reboot() {
if _need_confirm "Reboot system?"; then
reboot
@@ -32,7 +44,12 @@ sys_poweroff() {
fi
}
# Reload Waybar, Rofi, Swaync, and Rainbowborder.sh (SHIFT ALT R)
#######################################################
# #
# Reload Waybar, Rofi, Swaync #
# #
#######################################################
# (SHIFT ALT R)
reload_all() {
file_exists() {
[ -e "$1" ]
@@ -52,6 +69,13 @@ reload_all() {
sleep 0.5
swaync > /dev/null 2>&1 &
}
######################################
# #
# Reload Waybar #
# #
######################################
reload_waybar() {
_ps=(waybar rofi)
for _prs in "${_ps[@]}"; do
@@ -65,17 +89,37 @@ reload_waybar() {
if [[ -z $1 ]]; then
waybar &
fi
$notif "Reload Waybar"
notify-send -u low -i $notif "Reload Waybar"
}
######################################
# #
# Update Waybar #
# #
######################################
update_waybar() {
pkill -RTMIN+4 waybar
notify-send -u low -i $notif 'Refresh Waybar'
}
######################################
# #
# Reload Hyprland #
# #
######################################
reload_hypr() {
hyprctl reload
notify-send -u low -i $notif 'Reload Hyprland'
}
######################################
# #
# lockscreen(swaylock) #
# #
######################################
lock_screen() {
LOCKCONFIG="$HOME/.config/swaylock/config"
sleep 0.5s
@@ -84,7 +128,12 @@ lock_screen() {
}
# Volume Controller
######################################
# #
# Volume Controller #
# #
######################################
volume() {
get_volume() {
volume=$(pamixer --get-volume)
@@ -94,7 +143,6 @@ volume() {
echo "$volume%"
fi
}
get_icon() {
current=$(get_volume)
if [[ "$current" == "Muted" ]]; then
@@ -107,7 +155,6 @@ volume() {
echo "$iDIR/volume-high.png"
fi
}
notify_user() {
if [[ "$(get_volume)" == "Muted" ]]; then
notify-send -e -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: Muted"
@@ -115,21 +162,18 @@ volume() {
notify-send -e -h int:value:"$(get_volume | sed 's/%//')" -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: $(get_volume)"
fi
}
inc_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify_user
fi
pamixer -i 5 && notify_user
}
dec_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify_user
fi
pamixer -d 5 && notify_user
}
toggle_mute() {
if [ "$(pamixer --get-mute)" == "false" ]; then
pamixer -m && notify-send -e -u low -i "$iDIR/volume-mute.png" "Volume Switched OFF"
@@ -137,7 +181,6 @@ volume() {
pamixer -u && notify-send -e -u low -i "$(get_icon)" "Volume Switched ON"
fi
}
toggle_mic() {
if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
pamixer --default-source -m && notify-send -e -u low -i "$iDIR/microphone-mute.png" "Microphone Switched OFF"
@@ -145,7 +188,6 @@ volume() {
pamixer -u --default-source u && notify-send -e -u low -i "$iDIR/microphone.png" "Microphone Switched ON"
fi
}
get_mic_icon() {
current=$(pamixer --default-source --get-volume)
if [[ "$current" -eq "0" ]]; then
@@ -154,7 +196,6 @@ volume() {
echo "$iDIR/microphone.png"
fi
}
get_mic_volume() {
volume=$(pamixer --default-source --get-volume)
if [[ "$volume" -eq "0" ]]; then
@@ -163,27 +204,23 @@ volume() {
echo "$volume%"
fi
}
notify_mic_user() {
volume=$(get_mic_volume)
icon=$(get_mic_icon)
notify-send -e -h int:value:"$volume" -h "string:x-canonical-private-synchronous:volume_notif" -u low -i "$icon" "Mic-Level: $volume"
}
inc_mic_volume() {
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
pamixer --default-source -u && notify_mic_user
fi
pamixer --default-source -i 5 && notify_mic_user
}
dec_mic_volume() {
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
pamixer --default-source -u && notify_mic_user
fi
pamixer --default-source -d 5 && notify_mic_user
}
if [[ "$1" == "--get" ]]; then
get_volume
elif [[ "$1" == "--inc" ]]; then
@@ -207,8 +244,12 @@ volume() {
fi
}
######################################
# #
# ScreenShot #
# #
######################################
# ScreenShot
screenshot() {
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")
@@ -221,29 +262,24 @@ screenshot() {
[[ "$1" == "active" && ! -e "${active_window_path}" ]] && msg="Screenshot NOT Saved."
${notify_cmd_shot} "$msg"
}
countdown() {
for ((sec = $1; sec > 0; sec--)); do
notify-send -h string:x-canonical-private-synchronous:shot-notify -t 1000 -i "$iDIR"/timer.png "Taking shot in: $sec"
sleep 1
done
}
take_shot() {
cd "${dir}" && grim - | tee "$file" | wl-copy
sleep 2
notify_view "$1"
}
shotnow() { take_shot; }
shot_timer() { countdown "$1"; sleep 1 && take_shot; }
shot5() { shot_timer 5; }
shot10() { shot_timer 10; }
shotarea() {
tmpfile=$(mktemp)
area="$(slurp)"
[[ -z "$area" ]] && { notify-send -u low -i "$iDIR/picture.png" 'No area selected'; rm; "$tmpfile": return;}
grim -g "$area" - > "$tmpfile" && [[ -s "$tmpfile" ]] && {
wl-copy < "$tmpfile"
@@ -252,11 +288,8 @@ screenshot() {
}
rm "$tmpfile"
}
shotactive() { hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | grim -g - "${active_window_path}" && sleep 1 && notify_view "active"; }
[[ ! -d "$dir" ]] && mkdir -p "$dir"
case "$1" in
--now) shotnow ;;
--in5) shot5 ;;
@@ -265,23 +298,24 @@ screenshot() {
--active) shotactive ;;
*) echo -e "Available Options: --now --in5 --in10 --area --active"
esac
exit 0
}
# Brightness Controller
############################################################
# #
# Brightness Controller both keyboard & screen #
# #
############################################################
brightness() {
notification_timeout=1000
get_backlight() {
echo $(brightnessctl -m | cut -d, -f4)
}
get_kbd_backlight() {
brightnessctl -d '*::kbd_backlight' -m | cut -d, -f4 | tr -d '%'
}
get_icon() {
current=$(get_backlight | sed 's/%//')
[ "$current" -le "20" ] && icon="$iDIR/brightness-20.png" ||
@@ -290,19 +324,15 @@ get_icon() {
[ "$current" -le "80" ] && icon="$iDIR/brightness-80.png" ||
icon="$iDIR/brightness-100.png"
}
notify_user() {
notify-send -e -h string:x-canonical-private-synchronous:brightness_notif -h int:value:$current -u low -i "$icon" "Brightness: $current%"
}
change_backlight() {
brightnessctl set "$1" && get_icon && notify_user
}
change_kbd_backlight() {
brightnessctl -d '*::kbd_backlight' set "$1" && get_icon && notify_user
}
case "$1" in
"--get")
get_backlight
@@ -328,54 +358,54 @@ case "$1" in
esac
}
######################################
# #
# Battery Notifer #
# #
######################################
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
}
######################################
# #
# Polkit #
# #
######################################
polkit_(){
polkit=(
"/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1"
@@ -385,9 +415,7 @@ polkit_(){
"/usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1"
"/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1"
)
executed=false # Flag to track if a file has been executed
# Loop through the list of files
for file in "${polkit[@]}"; do
if [ -e "$file" ]; then
@@ -397,7 +425,6 @@ for file in "${polkit[@]}"; do
break
fi
done
# If none of the files were found, you can add a fallback command here
if [ "$executed" == false ]; then
echo "None of the specified files were found. Install a Polkit"