This commit is contained in:
sankalp committed 2024-03-08 11:55:51 +05:45
1 parent 75e52b850b
commit 754ea81164
23 files changed
+760 -883

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@
music(){
# Directory for icons
iDIR="$HOME/.config/swaync/icons"
iDIR="$HOME/dotfiles/swaync/icons"
# Note: You can add more options below with the following format:
# ["TITLE"]="link"
+4 -4
View File
@@ -75,7 +75,7 @@ main
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))
result=$(rofi -dmenu -kb-custom-1 "Control-Delete" -kb-custom-2 "Alt-Delete" -p "CTRL Del - Cliphist del || Alt Del - cliphist wipe" -config ~/dotfiles/rofi/config-long.rasi < <(cliphist list))
case "$?" in
1) exit ;;
@@ -115,9 +115,9 @@ edit() {
######################################
keybind() {
CONFIG=$(rofi -show file-browser-extended -file-browser-stdout -file-browser-dir "$HOME"/.config/keyb/bindings -config ~/.config/rofi/config-long.rasi)
CONFIG=$(fd --base-directory "$HOME/.config/keyb/bindings" --type f . | rofi -dmenu -config ~/dotfiles/rofi/config-long.rasi)
hyprctl dispatch exec "[float;size 45% 80%;center 1] kitty keyb -k '$CONFIG'"
hyprctl dispatch exec "[float;size 45% 80%;center 1] kitty keyb -k '$HOME/.config/keyb/bindings/$CONFIG'"
}
######################################
@@ -127,7 +127,7 @@ hyprctl dispatch exec "[float;size 45% 80%;center 1] kitty keyb -k '$CONFIG'"
######################################
emoji() {
A="$(rofi -dmenu -p "Emoji:" -config ~/.config/rofi/config-long.rasi < "$HOME/.config/hypr/configs/emojis" | cut -d ' ' -f 1 | tr -d '\n')"
A="$(rofi -dmenu -p "Emoji:" -config ~/dotfiles/rofi/config-long.rasi < "$HOME/.config/hypr/configs/emojis" | cut -d ' ' -f 1 | tr -d '\n')"
[[ -n "$A" ]] && wl-copy -- "$A"
}
+5 -189
View File
@@ -68,6 +68,8 @@ reload_all() {
waybar &
sleep 0.5
swaync > /dev/null 2>&1 &
# for cava-pywal (note, need to manually restart cava once wallpaper changes)
ln -sf "$HOME/.cache/wal/cava-colors" "$HOME/dotfiles/cava/config" || true
}
######################################
@@ -90,17 +92,7 @@ reload_waybar() {
waybar &
fi
notify-send -u low -i $notif "Reload Waybar"
}
######################################
# #
# Update Waybar #
# #
######################################
update_waybar() {
pkill -RTMIN+4 waybar
notify-send -u low -i $notif 'Refresh Waybar'
}
######################################
@@ -111,194 +103,18 @@ update_waybar() {
reload_hypr() {
hyprctl reload
$RunCMD linker
notify-send -u low -i $notif 'Reload Hyprland'
}
######################################
# #
# lockscreen(swaylock) #
# lockscreen(hyprlock) #
# #
######################################
lock_screen() {
LOCKCONFIG="$HOME/.config/swaylock/config"
sleep 0.5s
swaylock --config ${LOCKCONFIG} &
disown
}
######################################
# #
# Volume Controller #
# #
######################################
volume() {
get_volume() {
volume=$(pamixer --get-volume)
if [[ "$volume" -eq "0" ]]; then
echo "Muted"
else
echo "$volume%"
fi
}
get_icon() {
current=$(get_volume)
if [[ "$current" == "Muted" ]]; then
echo "$iDIR/volume-mute.png"
elif [[ "${current%\%}" -le 30 ]]; then
echo "$iDIR/volume-low.png"
elif [[ "${current%\%}" -le 60 ]]; then
echo "$iDIR/volume-mid.png"
else
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"
else
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"
elif [ "$(pamixer --get-mute)" == "true" ]; then
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"
elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
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
echo "$iDIR/microphone-mute.png"
else
echo "$iDIR/microphone.png"
fi
}
get_mic_volume() {
volume=$(pamixer --default-source --get-volume)
if [[ "$volume" -eq "0" ]]; then
echo "Muted"
else
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
inc_volume
elif [[ "$1" == "--dec" ]]; then
dec_volume
elif [[ "$1" == "--toggle" ]]; then
toggle_mute
elif [[ "$1" == "--toggle-mic" ]]; then
toggle_mic
elif [[ "$1" == "--get-icon" ]]; then
get_icon
elif [[ "$1" == "--get-mic-icon" ]]; then
get_mic_icon
elif [[ "$1" == "--mic-inc" ]]; then
inc_mic_volume
elif [[ "$1" == "--mic-dec" ]]; then
dec_mic_volume
else
get_volume
fi
}
############################################################
# #
# 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" ||
[ "$current" -le "40" ] && icon="$iDIR/brightness-40.png" ||
[ "$current" -le "60" ] && icon="$iDIR/brightness-60.png" ||
[ "$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
;;
"--inc")
change_backlight "+5%"
;;
"--dec")
change_backlight "5%-"
;;
"--get-kbd")
get_kbd_backlight
;;
"--inc-kbd")
change_kbd_backlight "+30%"
;;
"--dec-kbd")
change_kbd_backlight "30%-"
;;
*)
get_backlight
;;
esac
hyprlock
}
######################################
+40 -19
View File
@@ -105,6 +105,7 @@ random_wall() {
RANDOMPICS=${PICS[RANDOM % ${#PICS[@]}]} # Select a random image
swww img "${RANDOMPICS}" ${SWWW_PARAMS} # Set the randomly selected wallpaper
$linker
$RunCMD reload_all
else
echo "No images found in ${wallDIR}"
fi
@@ -122,7 +123,7 @@ auto_wall() {
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
| xargs -0 -I {} swww img "{}" ${SWWW_PARAMS} && $linker && $RunCMD reload_all
sleep $INTERVAL
done
}
@@ -145,13 +146,13 @@ select_wall() {
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)
choice=$(echo -en "$images\nRandom Choice" | rofi -dmenu -i -show-icons -theme-str "$(build_theme 3 5 6)" -config ~/dotfiles/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)
fi
wallpaper="$wallDIR/${choice#*icon\x1f}"
swww img $SWWW_PARAMS1 "$wallpaper" && $linker
swww img $SWWW_PARAMS1 "$wallpaper" && $linker && $RunCMD reload_all
else
echo "No wallpaper selected. Exiting."
exit 0
@@ -207,7 +208,7 @@ gamemode() {
else
notify-send -e -u normal -i "$notif" "All animations normal"
hyprctl keyword animations:enabled 1
swww init && swww img "$HOME/.config/rofi/.current_wallpaper"
swww init && swww img "$HOME/dotfiles/rofi/.current_wallpaper"
fi
}
@@ -265,23 +266,43 @@ notify-send -u low -i "$notif" "Keyboad Layout Changed to $new_layout"
######################################
linker() {
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/dotfiles/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
# Define the path to the swww cache directory
cache_dir="$HOME/.cache/swww/"
# Get a list of monitor outputs
monitor_outputs=($(ls "$cache_dir"))
# Initialize a flag to determine if the ln command was executed
ln_success=false
# Get first valid monitor
current_monitor=$(hyprctl -j monitors | jq -r '.[0].name')
echo $current_monitor
# Construct the full path to the cache file
cache_file="$cache_dir$current_monitor"
echo $cache_file
# 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=$(cat "$cache_file")
echo $wallpaper_path
# Copy the wallpaper to the location Rofi can access
if ln -sf "$wallpaper_path" "$HOME/dotfiles/rofi/.current_wallpaper"; then
ln_success=true # Set the flag to true upon successful execution
fi
done
if $ln_success; then # Add a message indicating whether the ln command was successful
echo "Wallpaper linked successfully."
else
echo "Failed to link wallpaper."
fi
# Check the flag before executing further commands
if [ "$ln_success" = true ]; then
# execute pywal
# wal -i "$wallpaper_path"
echo 'about to execute wal'
# execute pywal skipping tty and terminal changes
wal -i "$wallpaper_path" -s -t &
fi
# for cava-pywal (note, need to manually restart cava once wallpaper changes)
ln -sf "$HOME/.cache/wal/cava-colors" "$HOME/dotfiles/cava/config" || true
}