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

+1 -5
View File
@@ -30,14 +30,10 @@ exec-once = udiskie &
#exec-once = blueman-applet &
exec-once = bluetoothctl power off &
#clipboard manager
# clipboard manager
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 rainbow_border
@@ -43,10 +43,7 @@ bind = ALT, E, exec, $RunCMD edit
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
bind = ALT, B, exec, $RunCMD note
bind = ALT, C, exec, $RunCMD calc
bind = $mainMod, R, exec, $RunCMD sr
bind = $mainMod_SHIFT, N, exec, swaync-client -C
+23 -3
View File
@@ -5,7 +5,12 @@ CONFIG_FILE=~/.config/hypr/scripts/Ref.sh
source "$CONFIG_FILE"
# Toggle touchpad state. (SUPER SHIFT D)
######################################
# #
# Toggle touchpad state #
# #
######################################
toggle_touchpad() {
local status_file="$STATUS_FILE"
local action
@@ -22,8 +27,12 @@ toggle_touchpad() {
hyprctl keyword "device:$HYPRLAND_DEVICE:enabled" "$(cat "$status_file")"
}
######################################
# #
# Toggle wifi state #
# #
######################################
# Toggle Wifi
toggle_wifi() {
wifi_status=$(nmcli radio wifi)
if [ "$wifi_status" == "enabled" ]; then
@@ -35,7 +44,12 @@ toggle_wifi() {
fi
}
# Toggle Bluetooth
######################################
# #
# Toggle bluetooth state #
# #
######################################
toggle_bluetooth() {
if [ "$bluetooth_status" == "no" ]; then
bluetoothctl power on
@@ -46,6 +60,12 @@ toggle_bluetooth() {
fi
}
######################################
# #
# Enable/Disable Monitor #
# #
######################################
disable_edp1() {
enable_edp1
sleep 1
+17 -2
View File
@@ -1,5 +1,11 @@
#!/bin/bash
######################################
# #
# Music #
# #
######################################
music(){
# Directory for icons
iDIR="$HOME/.config/swaync/icons"
@@ -42,7 +48,12 @@ play_music() {
fi
}
# Function for music controls
######################################
# #
# Music Control #
# #
######################################
music_controls() {
local choice="$1"
@@ -78,7 +89,6 @@ play_pause() {
fi
}
# Main function
# Main function
main() {
local is_music_playing=$(playerctl --player=mpv status 2>/dev/null)
@@ -93,6 +103,11 @@ main() {
fi
}
######################################
# #
# Usage #
# #
######################################
while getopts "midnpks" flag; do
case "${flag}" in
+82 -200
View File
@@ -6,23 +6,12 @@ CONFIG_FILE=~/.config/hypr/scripts/Ref.sh
source "$CONFIG_FILE"
# Todo List (SHIFT ALT T)
todo() {
while cmd=$(rofi -dmenu -p "$prompt" -lines "$height" "$@" < "$file"); [ -n "$cmd" ]; do
if grep -q "^$cmd\$" "$file"; then
grep -v "^$cmd\$" "$file" > "$file.$$"
mv "$file.$$" "$file"
((height--))
else
echo "$cmd" >> "$file"
((height++))
fi
done
exit 0
}
######################################
# #
# Calculator #
# #
######################################
# Function For Calculator (ALT C)
calc() {
roficmd="rofi -dmenu -p Calc $@"
@@ -37,8 +26,12 @@ calc() {
done
}
######################################
# #
# Tmux Session #
# #
######################################
# Funtion for Tmux Sessions (ALT t)
tmux(){
tmux_sessions() {
tmux list-sessions | sed 's/: /| /' | column -t -s'|' -o' | '
@@ -74,96 +67,12 @@ main() {
main
}
######################################
# #
# Clipboard Manager #
# #
######################################
# Take note (ALT B)
note() {
if [[ ! -d "${NOTES_FOLDER}" ]]; then
mkdir -p "$NOTES_FOLDER"
fi
get_notes() {
ls "${NOTES_FOLDER}"
}
edit_note() {
note_location=$1
$NOTES_EDITOR "$note_location"
}
delete_note() {
local note=$1
local action=$(echo -e "Yes\nNo" | rofi -dmenu -p "Are you sure you want to delete $note? ")
case $action in
"Yes")
rm "$NOTES_FOLDER/$note"
main
;;
"No")
main
esac
}
note_context() {
local note=$1
local note_location="$NOTES_FOLDER/$note"
local action=$(echo -e "Edit\nDelete" | rofi -dmenu -p "$note > ")
case $action in
"Edit")
edit_note "$note_location"
exit 0;;
"Delete")
delete_note "$note"
exit 0;;
esac
exit 1
}
new_note() {
local title=$(echo -e "Cancel" | rofi -dmenu -p "Input title: ")
case "$title" in
"Cancel")
main
;;
*)
local file=$(echo "$title" | sed 's/ /_/g;s/\(.*\)/\L\1/g')
local template=$(cat <<- END
---
title: $title
date: $(date --rfc-3339=seconds)
author: $AUTHOR
---
# $title
END
)
note_location="$NOTES_FOLDER/$file.md"
if [ "$title" != "" ]; then
echo "$template" > "$note_location" | edit_note "$note_location"
exit 0
fi
;;
esac
}
main()
{
local all_notes="$(get_notes)"
local first_menu="New"
if [ "$all_notes" ];then
first_menu="New\n${all_notes}"
fi
local note=$(echo -e "$first_menu" | rofi -dmenu -p "󰚸 Notes")
case $note in
"New")
new_note
;;
"")
exit 1;;
*)
note_context "$note" && exit 0 # handle esc key in note_context
esac
exit 1
}
main
}
# Clipboard Manager. This script uses cliphist, rofi, and wl-copy. (SHIFT ALT C)
clip() {
while true; do
result=$(rofi -dmenu -kb-custom-1 "Control-Delete" -kb-custom-2 "Alt-Delete" -p "CTRL Del - Cliphist del || Alt Del - cliphist wipe" -config ~/.config/rofi/config-long.rasi < <(cliphist list))
@@ -178,7 +87,12 @@ clip() {
}
# Rofi menu for Quick Edit / View of Settings (SUPER E)
######################################
# #
# Quick Edit #
# #
######################################
edit() {
menu() {
options=("Env-variables" "Window-Rules" "Startup_Apps" "User-Keybinds" "Monitors" "Laptop-Keybinds" "User-Settings" "Default-Settings" "Default-Keybinds")
@@ -195,7 +109,12 @@ edit() {
}
# Powermenu (SUPER X)
######################################
# #
# Powermenu #
# #
######################################
powermenu() {
uptime_info=$(uptime -p | sed -e 's/up //g')
host=$(hostnamectl hostname)
@@ -223,35 +142,48 @@ powermenu() {
esac
}
# Keybinds (SUPER F1 )
######################################
# #
# Keybinds #
# #
######################################
keybind() {
CONFIG=$(rofi -show file-browser-extended -file-browser-stdout -file-browser-dir "$HOME"/.config/keyb/bindings -config ~/.config/rofi/config-long.rasi)
hyprctl dispatch exec "[float;size 45% 80%;center 1] kitty keyb -k '$CONFIG'"
}
# Emoji (ALT SLASH)
######################################
# #
# Emoji #
# #
######################################
emoji() {
A="$(rofi -dmenu -p "Emoji:" -config ~/.config/rofi/config-long.rasi < "$HOME/.config/hypr/configs/emojis" | cut -d ' ' -f 1 | tr -d '\n')"
[[ -n "$A" ]] && wl-copy -- "$A"
}
######################################
# #
# Bluetooth #
# #
######################################
bluetooth(){
divider="—————————————————————————————————————————————————————————"
goback=" Back"
theme=~/.config/rofi/config-long.rasi
# Checks if bluetooth controller is powered on
power_on() {
power_on() { # Checks if bluetooth controller is powered on
if bluetoothctl show | grep -q "Powered: yes"; then
return 0
else
return 1
fi
}
# Toggles power state
toggle_power() {
toggle_power() { # Toggles power state
if power_on; then
bluetoothctl power off
show_menu
@@ -263,9 +195,7 @@ toggle_power() {
show_menu
fi
}
# Checks if controller is scanning for new devices
scan_on() {
scan_on() { # Checks if controller is scanning for new devices
if bluetoothctl show | grep -q "Discovering: yes"; then
echo "󰂰 Scan: ON"
return 0
@@ -274,9 +204,7 @@ scan_on() {
return 1
fi
}
# Toggles scanning state
toggle_scan() {
toggle_scan() { # Toggles scanning state
if scan_on; then
kill $(pgrep -f "bluetoothctl scan on")
bluetoothctl scan off
@@ -288,9 +216,7 @@ toggle_scan() {
show_menu
fi
}
# Checks if controller is able to pair to devices
pairable_on() {
pairable_on() { # Checks if controller is able to pair to devices
if bluetoothctl show | grep -q "Pairable: yes"; then
echo "󰂴 Pairable: ON"
return 0
@@ -299,9 +225,7 @@ pairable_on() {
return 1
fi
}
# Toggles pairable state
toggle_pairable() {
toggle_pairable() { # Toggles pairable state
if pairable_on; then
bluetoothctl pairable off
show_menu
@@ -310,9 +234,7 @@ toggle_pairable() {
show_menu
fi
}
# Checks if controller is discoverable by other devices
discoverable_on() {
discoverable_on() { # Checks if controller is discoverable by other devices
if bluetoothctl show | grep -q "Discoverable: yes"; then
echo "󰂳 Discoverable: ON"
return 0
@@ -321,9 +243,7 @@ discoverable_on() {
return 1
fi
}
# Toggles discoverable state
toggle_discoverable() {
toggle_discoverable() { # Toggles discoverable state
if discoverable_on; then
bluetoothctl discoverable off
show_menu
@@ -332,9 +252,7 @@ toggle_discoverable() {
show_menu
fi
}
# Checks if a device is connected
device_connected() {
device_connected() { # Checks if a device is connected
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Connected: yes"; then
return 0
@@ -342,9 +260,7 @@ device_connected() {
return 1
fi
}
# Toggles device connection
toggle_connection() {
toggle_connection() { # Toggles device connection
if device_connected $1; then
bluetoothctl disconnect $1
device_menu "$device"
@@ -353,9 +269,7 @@ toggle_connection() {
device_menu "$device"
fi
}
# Checks if a device is paired
device_paired() {
device_paired() { # Checks if a device is paired
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Paired: yes"; then
echo "Paired: "
@@ -365,9 +279,7 @@ device_paired() {
return 1
fi
}
# Toggles device paired state
toggle_paired() {
toggle_paired() { # Toggles device paired state
if device_paired $1; then
bluetoothctl remove $1
device_menu "$device"
@@ -376,9 +288,7 @@ toggle_paired() {
device_menu "$device"
fi
}
# Checks if a device is trusted
device_trusted() {
device_trusted() { # Checks if a device is trusted
device_info=$(bluetoothctl info "$1")
if echo "$device_info" | grep -q "Trusted: yes"; then
echo "Trusted: "
@@ -388,9 +298,7 @@ device_trusted() {
return 1
fi
}
# Toggles device connection
toggle_trust() {
toggle_trust() { # Toggles device connection
if device_trusted $1; then
bluetoothctl untrust $1
device_menu "$device"
@@ -399,10 +307,7 @@ toggle_trust() {
device_menu "$device"
fi
}
# Prints a short string with the current bluetooth status
# Useful for status bars like polybar, etc.
print_status() {
print_status() { # Prints a short string with the current bluetooth status
if power_on; then
printf ''
@@ -427,30 +332,23 @@ print_status() {
echo ""
fi
}
# A submenu for a specific device that allows connecting, pairing, and trusting
device_menu() {
device_menu() { # A submenu for a specific device that allows connecting, pairing, and trusting
device=$1
# Get device name and mac address
device_name=$(echo $device | cut -d ' ' -f 3-)
device_name=$(echo $device | cut -d ' ' -f 3-) # Get device name and mac address
mac=$(echo $device | cut -d ' ' -f 2)
# Build options
if device_connected $mac; then
if device_connected $mac; then # Build options
connected="Connected: "
else
connected="Connected: "
fi
paired=$(device_paired $mac)
trusted=$(device_trusted $mac)
options="$connected\n$paired\n$trusted\n$goback\n󰍃 Exit"
# Open rofi menu, read chosen option
chosen="$(echo -e "$options" | $rofi_command "$device_name")"
# Match chosen option to command
case $chosen in
options="$connected\n$paired\n$trusted\n$divider\n$goback\n󰍃 Exit"n
chosen="$(echo -e "$options" | $rofi_command "$device_name")" # Open rofi menu, read chosen optio
case $chosen in # Match chosen option to command
"" | $divider)
echo "No option chosen."
;;
$connected)
toggle_connection $mac
;;
@@ -465,34 +363,23 @@ device_menu() {
;;
esac
}
# Opens a rofi menu with current bluetooth status and options to connect
show_menu() {
# Get menu options
if power_on; then
show_menu() { # Opens a rofi menu with current bluetooth status and options to connect
if power_on; then # Get menu options
power="󰂯 Power: ON"
# Human-readable names of devices, one per line
# If scan is off, will only list paired devices
devices=$(bluetoothctl devices | grep Device | cut -d ' ' -f 3-)
# Get controller flags
scan=$(scan_on)
devices=$(bluetoothctl devices | grep Device | cut -d ' ' -f 3-)s # Human-readable names of devices, one per line. If scan is off, will only list paired devices
scan=$(scan_on) # Get controller flag
pairable=$(pairable_on)
discoverable=$(discoverable_on)
# Options passed to rofi
options="$devices\n$power\n$scan\n$pairable\n$discoverable\n󰍃 Exit"
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\n󰍃 Exit" # Options passed to rofi
else
power="󰂲 Power: OFF"
options="$power\n󰍃 Exit"
fi
# Open rofi menu, read chosen option
chosen="$(echo -e "$options" | $rofi_command " Bluetooth")"
# Match chosen option to command
case $chosen in
chosen="$(echo -e "$options" | $rofi_command " Bluetooth")" # Open rofi menu, read chosen option
case $chosen in # Match chosen option to command
"" | $divider)
echo "No option chosen."
;;
$power)
toggle_power
;;
@@ -507,15 +394,11 @@ show_menu() {
;;
*)
device=$(bluetoothctl devices | grep "$chosen")
# Open a submenu if a device is selected
if [[ $device ]]; then device_menu "$device"; fi
if [[ $device ]]; then device_menu "$device"; fi # Open a submenu if a device is selected
;;
esac
}
# Rofi command to pipe into, can add any options here
rofi_command="rofi -dmenu -no-fixed-num-lines -yoffset -100 -i -theme $theme -p"
rofi_command="rofi -dmenu -no-fixed-num-lines -yoffset -100 -i -theme $theme -p" # Rofi command to pipe into, can add any options here
case "$1" in
--status)
print_status
@@ -524,5 +407,4 @@ case "$1" in
show_menu
;;
esac
}
}
+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"
+97 -93
View File
@@ -5,7 +5,12 @@ CONFIG_FILE=~/.config/hypr/scripts/Ref.sh
source "$CONFIG_FILE"
# Change blur (SUPER SHIFT Q)
######################################
# #
# Toggle Blur #
# #
######################################
toggle_blur (){
STATE=$(hyprctl -j getoption decoration:blur:passes | jq ".int")
@@ -20,6 +25,12 @@ toggle_blur (){
fi
}
######################################
# #
# Toggle Animation #
# #
######################################
toggle_animation() {
STATE=$(hyprctl -j getoption animations:enabled | jq ".int")
if [ "${STATE}" = "1" ]; then
@@ -32,21 +43,30 @@ toggle_animation() {
}
######################################
# #
# Rainbow Border #
# #
######################################
rainbow_border() {
function random_hex() {
random_hex=("0xff$(openssl rand -hex 3)")
echo $random_hex
}
hyprctl keyword general:col.active_border $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) 270deg
hyprctl keyword general:col.inactive_border $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) 270deg
}
# Change layout to master & dwindle (SUPER SPACE)
################################################
# #
# Change Layout Master to Dwindle #
# #
################################################
change_layout() {
LAYOUT=$(hyprctl -j getoption general:layout | jq -r '.str')
case $LAYOUT in
"master")
hyprctl keyword general:layout dwindle
@@ -71,7 +91,11 @@ change_layout() {
}
# Script for Random Wallpaper ( SHIFT ALT W)
######################################
# #
# Random Wallpaper #
# #
######################################
random_wall() {
swww query || swww init
@@ -87,23 +111,28 @@ random_wall() {
}
# Change Wallpaper automatically after 30min
######################################
# #
# Auto Wallpaper Changer #
# #
######################################
auto_wall() {
INTERVAL=1800 # This controls (in seconds) when to switch to the next image
while true; do
find "$wallDIR" -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" -o -name "*.gif" \) -print0 \
| shuf -z -n 1 \
| xargs -0 -I {} swww img "{}" ${SWWW_PARAMS} && $linker
sleep $INTERVAL
done
}
######################################
# #
# Wallpaper Selector #
# #
######################################
# selecting wallpapers (SUPER W)
select_wall() {
build_theme() {
rows="$1"
@@ -115,10 +144,8 @@ select_wall() {
echo "Error: Wallpaper directory not found." >&2
exit 1
fi
images=$(find "$wallDIR" -maxdepth 1 -type f -printf "%f\x00icon\x1f$wallDIR/%f\n" | sort -n)
choice=$(echo -en "$images\nRandom Choice" | rofi -dmenu -i -show-icons -theme-str "$(build_theme 3 5 6)" -config ~/.config/rofi/config-wallpaper.rasi)
if [ -n "$choice" ]; then
if [ "$choice" = "Random Choice" ]; then
choice=$(find "$wallDIR" -type f -maxdepth 1 -printf "%f\n" | shuf -n1)
@@ -131,7 +158,12 @@ select_wall() {
fi
}
# Waybar Layout (ALT W)
######################################
# #
# Waybar Layout #
# #
######################################
waybar_layout() {
menu() {
find "$config_dir" -maxdepth 1 -type f -exec basename {} \; | sort
@@ -161,7 +193,11 @@ restart_waybar_if_needed() {
main
}
# Toggle animations (SUPER SHIFT A)
######################################
# #
# GameMode #
# #
######################################)
gamemode() {
status=$(hyprctl getoption animations:enabled -j | jq ".int")
if [[ $status -eq 1 ]]; then
@@ -175,6 +211,12 @@ gamemode() {
fi
}
######################################
# #
# Toggle Opaque #
# #
######################################
enable_opaque() {
sleep 0.2
hyprctl setprop address:$(hyprctl -j activewindow | jq -r -c ".address") forceopaque 0 lock
@@ -184,15 +226,11 @@ disable_opaque() {
hyprctl setprop address:$(hyprctl -j activewindow | jq -r -c ".address") forceopaque 1 lock
}
welcome() {
sleep 1
######################################
# Keyboard Layout Switcher #
# #
######################################
name=$(whoami)
notify-send "Hello" "${name}?,you're back? welcome what will we do today!"
}
# Switch Keyboard Layout (ALT F1)
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)
@@ -220,34 +258,26 @@ echo "$new_layout" > "$layout_f"
notify-send -u low -i "$notif" "Keyboad Layout Changed to $new_layout"
}
# Symbolic link for wallpaper
######################################
# #
# Symbolic Linker for Wallpaper #
# #
######################################
linker() {
# Define the path to the swww cache directory
cache_dir="$HOME/.cache/swww/"
# Get a list of monitor outputs
monitor_outputs=("$cache_dir"/*)
# Initialize a flag to determine if the ln command was executed
ln_success=false
# Loop through monitor outputs
for cache_file in "${monitor_outputs[@]}"; do
# Check if the cache file exists for the current monitor output
if [ -f "$cache_file" ]; then
# Get the wallpaper path from the cache file
wallpaper_path=$(<"$cache_file")
# Copy the wallpaper to the location Rofi can access
if ln -sf "$wallpaper_path" "$HOME/.config/rofi/.current_wallpaper"; then
cache_dir="$HOME/.cache/swww/" # Define the path to the swww cache directory
monitor_outputs=("$cache_dir"/*) # Get a list of monitor outputs
ln_success=false # Initialize a flag to determine if the ln command was executed
for cache_file in "${monitor_outputs[@]}"; do # Loop through monitor outputs
if [ -f "$cache_file" ]; then # Check if the cache file exists for the current monitor output
wallpaper_path=$(<"$cache_file") # Get the wallpaper path from the cache file
if ln -sf "$wallpaper_path" "$HOME/.config/rofi/.current_wallpaper"; then # Copy the wallpaper to the location Rofi can access
ln_success=true # Set the flag to true upon successful execution
break # Exit the loop after processing the first found monitor output
fi
fi
done
# Add a message indicating whether the ln command was successful
if $ln_success; then
if $ln_success; then # Add a message indicating whether the ln command was successful
echo "Wallpaper linked successfully."
else
echo "Failed to link wallpaper."
@@ -255,13 +285,18 @@ fi
}
caway() {
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
######################################
# #
# Cava visulizer #
# #
######################################
caway() {
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
BARS=8;
FRAMERATE=60;
EQUILIZER=1;
# Get script options
while getopts 'b:f:m:eh' flag; do
case "${flag}" in
@@ -280,28 +315,21 @@ while getopts 'b:f:m:eh' flag; do
;;
esac
done
bar="▁▂▃▄▅▆▇█"
dict="s/;//g;"
# creating "dictionary" to replace char with bar + thin space " "
i=0
i=0 # creating "dictionary" to replace char with bar + thin space " "
while [ $i -lt ${#bar} ]
do
dict="${dict}s/$i/${bar:$i:1} /g;"
i=$((i=i+1))
done
# Remove last extra thin space
dict="${dict}s/.$//;"
dict="${dict}s/.$//;" # Remove last extra thin space
clean_create_pipe() {
if [ -p $1 ]; then
unlink $1
fi
mkfifo $1
}
kill_pid_file() {
if [[ -f $1 ]]; then
while read pid; do
@@ -309,16 +337,10 @@ kill_pid_file() {
done < $1
fi
}
# PID of the cava process and while loop launched from the script
cava_waybar_pid="/tmp/cava_waybar_pid"
# Clean pipe for cava
cava_waybar_pipe="/tmp/cava_waybar.fifo"
cava_waybar_pid="/tmp/cava_waybar_pid" # PID of the cava process and while loop launched from the script
cava_waybar_pipe="/tmp/cava_waybar.fifo" # Clean pipe for cava
clean_create_pipe $cava_waybar_pipe
# Custom cava config
cava_waybar_config="/tmp/cava_waybar_config"
cava_waybar_config="/tmp/cava_waybar_config" # Custom cava config
echo "
[general]
mode = normal
@@ -332,40 +354,22 @@ data_format = ascii
ascii_max_range = 7
" > $cava_waybar_config
# Clean pipe for playerctl
playerctl_waybar_pipe="/tmp/playerctl_waybar.fifo"
playerctl_waybar_pipe="/tmp/playerctl_waybar.fifo" # Clean pipe for playerctl
clean_create_pipe $playerctl_waybar_pipe
# playerctl output into playerctl_waybar_pipe
playerctl -a metadata --format '{"tooltip": "{{playerName}} : {{markup_escape(artist)}} - {{markup_escape(title)}}", "alt": "{{status}}", "class": "{{status}}"}' -F > "$playerctl_waybar_pipe" &
# Read the playerctl o/p via its fifo pipe
while read -r line; do
# Kill the cava process to stop the input to cava_waybar_pipe
kill_pid_file $cava_waybar_pid
playerctl -a metadata --format '{"tooltip": "{{playerName}} : {{markup_escape(artist)}} - {{markup_escape(title)}}", "alt": "{{status}}", "class": "{{status}}"}' -F > "$playerctl_waybar_pipe" & # playerctl output into playerctl_waybar_pipe
while read -r line; do # Read the playerctl o/p via its fifo pipe
kill_pid_file $cava_waybar_pid # Kill the cava process to stop the input to cava_waybar_pipe
echo "$line" | jq --unbuffered --compact-output
# If the class says "Playing" and equilizer is enabled
# then show the cava equilizer
if [[ $EQUILIZER == 1 && $(echo $line | jq -r '.class') == 'Playing' ]]; then
# Show the playing title for 2 seconds
sleep 2
# cava output into cava_waybar_pipe
cava -p $cava_waybar_config >$cava_waybar_pipe &
# Save the PID of child process
echo $! > $cava_waybar_pid
# Read the cava o/p via its fifo pipe
while read -r cmd2; do
# Change the "text" key to bars
echo "$line" | jq --arg a $(echo $cmd2 | sed "$dict") '.text = $a' --unbuffered --compact-output
sleep 2 # Show the playing title for 2 seconds
cava -p $cava_waybar_config >$cava_waybar_pipe & # cava output into cava_waybar_pipe
echo $! > $cava_waybar_pid # Save the PID of child process
while read -r cmd2; do # Read the cava o/p via its fifo pipe
echo "$line" | jq --arg a $(echo $cmd2 | sed "$dict") '.text = $a' --unbuffered --compact-output # Change the "text" key to bars
done < $cava_waybar_pipe & # Do this fifo read in background
# Save the while loop PID into the file as well
echo $! >> $cava_waybar_pid
echo $! >> $cava_waybar_pid # Save the while loop PID into the file as well
fi
done < $playerctl_waybar_pipe
}
+8 -7
View File
@@ -10,7 +10,6 @@ source "$CONFIG_FILE"
# Define menu options as an associative array
declare -A menu_options=(
#waybar
["wbt ToggleWaybar"]="killall -SIGUSR1 waybar"
["wbl WaybarLayout"]="$RunCMD waybar_layout"
@@ -32,12 +31,10 @@ declare -A menu_options=(
#RunCMD
["; Launcher"]="rofi -show drun -modi drun,filebrowser,run,window -theme $HOME/.config/rofi/launcher.rasi"
["cb Clipboard"]="$RunCMD clip"
["rmc RunCMDMusic"]="$RunCMD music -m"
["rm RunCMDMusic"]="$RunCMD music -m"
["emj RunCMDEmoji"]="$RunCMD emoji"
["cc Calculator"]="$RunCMD calc"
["td Todo"]="$RunCMD todo"
["tx Tmux"]="$RunCMD tmux"
["nt Note"]="$RunCMD note"
["kb Kebinds"]="$RunCMD keybind"
["qe Edits"]="$RunCMD edit"
#System
@@ -45,18 +42,22 @@ declare -A menu_options=(
["rr Reboot"]="$RunCMD sys_reboot"
["pm Powermenu"]="$RunCMD powermenu"
["cn Close Notifactions"]="swaync-client -C"
["dm0"]="$RunCMD enable_edp1"
["dm1"]="$RunCMD enable_edp1"
["dm0 disable monitor"]="$RunCMD disable_edp1"
["dm1 enable monitor"]="$RunCMD enable_edp1"
["tt Touchpad"]="$RunCMD toggle_touchpad"
["tbt Bluetooth"]="$RunCMD toggle_bluetooth"
["tw Wifi"]="$RunCMD toggle_wifi"
["kb Keyboard switcher"]="$RunCMD kb_changer"
["bt Bluetooth"]="$RunCMD bluetooth"
#Misc
["ff Firefox"]="firefox"
["ffp Firefox"]="firefox --private-window"
["dd Discord"]="discord"
["sr ScreenRecord"]="$RunCMD sr"
["lg Lazygit"]="kitty lazygit"
["vi Nvim"]="kitty nvim"
["yz Yazi"]="kitty yazi"
["cd Codium"]="codium"
["cd Codium"]="codium --disable-gpu"
)
# Main function