diff options
| author | Ja.KooLit <85185940+JaKooLit@users.noreply.github.com> | 2025-07-25 21:31:54 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-25 21:31:54 +0900 |
| commit | dd889d3aac40075ee73f76290c69ccc698673817 (patch) | |
| tree | 67dc1026bc09a93cb5250e1c28adda15c592aff4 /config/hypr/scripts | |
| parent | 637025eeb60391e5cc17c883aa6ee95799acac76 (diff) | |
| parent | aa3c94f1ad44038d6a71ee8e12a704e6089e31f6 (diff) | |
Merge pull request #775 from JaKooLit/development
Development to main
Diffstat (limited to 'config/hypr/scripts')
| -rw-r--r-- | config/hypr/scripts/Battery.sh | 9 | ||||
| -rwxr-xr-x | config/hypr/scripts/Brightness.sh | 103 | ||||
| -rwxr-xr-x | config/hypr/scripts/BrightnessKbd.sh | 2 | ||||
| -rwxr-xr-x | config/hypr/scripts/Dropterminal.sh | 293 | ||||
| -rwxr-xr-x | config/hypr/scripts/Refresh.sh | 4 | ||||
| -rwxr-xr-x | config/hypr/scripts/RefreshNoWaybar.sh | 2 | ||||
| -rwxr-xr-x | config/hypr/scripts/RofiThemeSelector.sh | 199 | ||||
| -rwxr-xr-x | config/hypr/scripts/Volume.sh | 14 | ||||
| -rwxr-xr-x | config/hypr/scripts/WaybarLayout.sh | 5 | ||||
| -rwxr-xr-x | config/hypr/scripts/WaybarStyles.sh | 5 | ||||
| -rw-r--r-- | config/hypr/scripts/sddm_wallpaper-v2.sh | 76 | ||||
| -rwxr-xr-x | config/hypr/scripts/sddm_wallpaper.sh | 56 |
12 files changed, 639 insertions, 129 deletions
diff --git a/config/hypr/scripts/Battery.sh b/config/hypr/scripts/Battery.sh new file mode 100644 index 00000000..d7830058 --- /dev/null +++ b/config/hypr/scripts/Battery.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +for i in {0..3}; do + if [ -f /sys/class/power_supply/BAT$i/capacity ]; then + battery_level=$(cat /sys/class/power_supply/BAT$i/status) + battery_capacity=$(cat /sys/class/power_supply/BAT$i/capacity) + echo "Battery: $battery_capacity% ($battery_level)" + fi +done diff --git a/config/hypr/scripts/Brightness.sh b/config/hypr/scripts/Brightness.sh index 8e5d525a..63fd02f3 100755 --- a/config/hypr/scripts/Brightness.sh +++ b/config/hypr/scripts/Brightness.sh @@ -6,69 +6,64 @@ iDIR="$HOME/.config/swaync/icons" notification_timeout=1000 step=10 # INCREASE/DECREASE BY THIS VALUE -# Get brightness -get_backlight() { - brightnessctl -m | cut -d, -f4 | sed 's/%//' +# Get current brightness as an integer (without %) +get_brightness() { + brightnessctl -m | cut -d, -f4 | tr -d '%' } -# Get icons -get_icon() { - current=$(get_backlight) - if [ "$current" -le "20" ]; then - icon="$iDIR/brightness-20.png" - elif [ "$current" -le "40" ]; then - icon="$iDIR/brightness-40.png" - elif [ "$current" -le "60" ]; then - icon="$iDIR/brightness-60.png" - elif [ "$current" -le "80" ]; then - icon="$iDIR/brightness-80.png" - else - icon="$iDIR/brightness-100.png" - fi +# Determine the icon based on brightness level +get_icon_path() { + local brightness=$1 + local level=$(( (brightness + 19) / 20 * 20 )) # Round up to next 20 + if (( level > 100 )); then + level=100 + fi + echo "$iDIR/brightness-${level}.png" } -# Notify -notify_user() { - notify-send -e -h string:x-canonical-private-synchronous:brightness_notif -h int:value:$current -u low -i $icon "Screen" "Brightness:$current%" +# Send notification +send_notification() { + local brightness=$1 + local icon_path=$2 + + notify-send -e \ + -h string:x-canonical-private-synchronous:brightness_notif \ + -h int:value:"$brightness" \ + -u low \ + -i "$icon_path" \ + "Screen" "Brightness: ${brightness}%" } -# Change brightness -change_backlight() { - local current_brightness - current_brightness=$(get_backlight) +# Change brightness and notify +change_brightness() { + local delta=$1 + local current new icon + + current=$(get_brightness) + new=$((current + delta)) - # Calculate new brightness - if [[ "$1" == "+${step}%" ]]; then - new_brightness=$((current_brightness + step)) - elif [[ "$1" == "${step}%-" ]]; then - new_brightness=$((current_brightness - step)) - fi + # Clamp between 5 and 100 + (( new < 5 )) && new=5 + (( new > 100 )) && new=100 - # Ensure new brightness is within valid range - if (( new_brightness < 5 )); then - new_brightness=5 - elif (( new_brightness > 100 )); then - new_brightness=100 - fi + brightnessctl set "${new}%" - brightnessctl set "${new_brightness}%" - get_icon - current=$new_brightness - notify_user + icon=$(get_icon_path "$new") + send_notification "$new" "$icon" } -# Execute accordingly +# Main case "$1" in - "--get") - get_backlight - ;; - "--inc") - change_backlight "+${step}%" - ;; - "--dec") - change_backlight "${step}%-" - ;; - *) - get_backlight - ;; -esac + "--get") + get_brightness + ;; + "--inc") + change_brightness "$step" + ;; + "--dec") + change_brightness "-$step" + ;; + *) + get_brightness + ;; +esac
\ No newline at end of file diff --git a/config/hypr/scripts/BrightnessKbd.sh b/config/hypr/scripts/BrightnessKbd.sh index 4c56bc03..24737b73 100755 --- a/config/hypr/scripts/BrightnessKbd.sh +++ b/config/hypr/scripts/BrightnessKbd.sh @@ -26,7 +26,7 @@ get_icon() { } # Notify notify_user() { - notify-send -e -h string:x-canonical-private-synchronous:brightness_notif -h int:value:$current -u low -i "$icon" "Keyboard" "Brightness:$current%" + notify-send -e -h string:x-canonical-private-synchronous:brightness_notif -h int:value:$current -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$icon" "Keyboard" "Brightness:$current%" } # Change brightness diff --git a/config/hypr/scripts/Dropterminal.sh b/config/hypr/scripts/Dropterminal.sh new file mode 100755 index 00000000..fa5b899b --- /dev/null +++ b/config/hypr/scripts/Dropterminal.sh @@ -0,0 +1,293 @@ +#!/bin/bash +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# Dropdown Terminal +# Usage: ./Dropdown.sh [-d] <terminal_command> +# Example: ./Dropdown.sh foot +# ./Dropdown.sh -d foot (with debug output) +# ./Dropdown.sh "kitty -e zsh" +# ./Dropdown.sh "alacritty --working-directory /home/user" + +DEBUG=false +SPECIAL_WS="special:scratchpad" +ADDR_FILE="/tmp/dropdown_terminal_addr" + +# Dropdown size and position configuration (percentages) +WIDTH_PERCENT=50 # Width as percentage of screen width +HEIGHT_PERCENT=50 # Height as percentage of screen height +X_PERCENT=25 # X position as percentage from left (25% centers a 50% width window) +Y_PERCENT=5 # Y position as percentage from top + +# Animation settings +ANIMATION_DURATION=100 # milliseconds +SLIDE_STEPS=5 +SLIDE_DELAY=5 # milliseconds between steps + +# Parse arguments +if [ "$1" = "-d" ]; then + DEBUG=true + shift +fi + +TERMINAL_CMD="$1" + +# Debug echo function +debug_echo() { + if [ "$DEBUG" = true ]; then + echo "$@" + fi +} + +# Validate input +if [ -z "$TERMINAL_CMD" ]; then + echo "Missing terminal command. Usage: $0 [-d] <terminal_command>" + echo "Examples:" + echo " $0 foot" + echo " $0 -d foot (with debug output)" + echo " $0 'kitty -e zsh'" + echo " $0 'alacritty --working-directory /home/user'" + echo "" + echo "Edit the script to modify size and position:" + echo " WIDTH_PERCENT - Width as percentage of screen (default: 50)" + echo " HEIGHT_PERCENT - Height as percentage of screen (default: 50)" + echo " X_PERCENT - X position from left as percentage (default: 25)" + echo " Y_PERCENT - Y position from top as percentage (default: 5)" + exit 1 +fi + +# Function to get window geometry +get_window_geometry() { + local addr="$1" + hyprctl clients -j | jq -r --arg ADDR "$addr" '.[] | select(.address == $ADDR) | "\(.at[0]) \(.at[1]) \(.size[0]) \(.size[1])"' +} + +# Function to animate window slide down (show) +animate_slide_down() { + local addr="$1" + local target_x="$2" + local target_y="$3" + local width="$4" + local height="$5" + + debug_echo "Animating slide down for window $addr to position $target_x,$target_y" + + # Start position (above screen) + local start_y=$((target_y - height - 50)) + + # Calculate step size + local step_y=$(((target_y - start_y) / SLIDE_STEPS)) + + # Move window to start position instantly (off-screen) + hyprctl dispatch movewindowpixel "exact $target_x $start_y,address:$addr" >/dev/null 2>&1 + sleep 0.05 + + # Animate slide down + for i in $(seq 1 $SLIDE_STEPS); do + local current_y=$((start_y + (step_y * i))) + hyprctl dispatch movewindowpixel "exact $target_x $current_y,address:$addr" >/dev/null 2>&1 + sleep 0.03 + done + + # Ensure final position is exact + hyprctl dispatch movewindowpixel "exact $target_x $target_y,address:$addr" >/dev/null 2>&1 +} + +# Function to animate window slide up (hide) +animate_slide_up() { + local addr="$1" + local start_x="$2" + local start_y="$3" + local width="$4" + local height="$5" + + debug_echo "Animating slide up for window $addr from position $start_x,$start_y" + + # End position (above screen) + local end_y=$((start_y - height - 50)) + + # Calculate step size + local step_y=$(((start_y - end_y) / SLIDE_STEPS)) + + # Animate slide up + for i in $(seq 1 $SLIDE_STEPS); do + local current_y=$((start_y - (step_y * i))) + hyprctl dispatch movewindowpixel "exact $start_x $current_y,address:$addr" >/dev/null 2>&1 + sleep 0.03 + done + + debug_echo "Slide up animation completed" +} + +# Function to get monitor info for centering +get_monitor_info() { + hyprctl monitors -j | jq -r '.[0] | "\(.x) \(.y) \(.width) \(.height)"' +} + +# Function to calculate dropdown position +calculate_dropdown_position() { + local monitor_info=$(get_monitor_info) + local mon_x=$(echo $monitor_info | cut -d' ' -f1) + local mon_y=$(echo $monitor_info | cut -d' ' -f2) + local mon_width=$(echo $monitor_info | cut -d' ' -f3) + local mon_height=$(echo $monitor_info | cut -d' ' -f4) + + # Calculate position and size based on percentages + local width=$((mon_width * WIDTH_PERCENT / 100)) + local height=$((mon_height * HEIGHT_PERCENT / 100)) + local x=$((mon_x + (mon_width * X_PERCENT / 100))) + local y=$((mon_y + (mon_height * Y_PERCENT / 100))) + + echo "$x $y $width $height" +} + +# Get the current workspace +CURRENT_WS=$(hyprctl activeworkspace -j | jq -r '.id') + +# Function to get stored terminal address +get_terminal_address() { + if [ -f "$ADDR_FILE" ] && [ -s "$ADDR_FILE" ]; then + cat "$ADDR_FILE" + fi +} + +# Function to check if terminal exists +terminal_exists() { + local addr=$(get_terminal_address) + if [ -n "$addr" ]; then + hyprctl clients -j | jq -e --arg ADDR "$addr" 'any(.[]; .address == $ADDR)' >/dev/null 2>&1 + else + return 1 + fi +} + +# Function to check if terminal is in special workspace +terminal_in_special() { + local addr=$(get_terminal_address) + if [ -n "$addr" ]; then + hyprctl clients -j | jq -e --arg ADDR "$addr" 'any(.[]; .address == $ADDR and .workspace.name == "special:scratchpad")' >/dev/null 2>&1 + else + return 1 + fi +} + +# Function to spawn terminal and capture its address +spawn_terminal() { + debug_echo "Creating new dropdown terminal with command: $TERMINAL_CMD" + + # Calculate dropdown position for later use + pos_info=$(calculate_dropdown_position) + target_x=$(echo $pos_info | cut -d' ' -f1) + target_y=$(echo $pos_info | cut -d' ' -f2) + width=$(echo $pos_info | cut -d' ' -f3) + height=$(echo $pos_info | cut -d' ' -f4) + + debug_echo "Target position: ${target_x}x${target_y}, size: ${width}x${height}" + + # Get window count before spawning + windows_before=$(hyprctl clients -j) + count_before=$(echo "$windows_before" | jq 'length') + + # Launch terminal directly in special workspace to avoid visible spawn + hyprctl dispatch exec "[float; size $width $height; workspace special:scratchpad silent] $TERMINAL_CMD" + + # Wait for window to appear + sleep 0.1 + + # Get windows after spawning + windows_after=$(hyprctl clients -j) + count_after=$(echo "$windows_after" | jq 'length') + + new_addr="" + + if [ "$count_after" -gt "$count_before" ]; then + # Find the new window by comparing before/after lists + new_addr=$(comm -13 \ + <(echo "$windows_before" | jq -r '.[].address' | sort) \ + <(echo "$windows_after" | jq -r '.[].address' | sort) \ + | head -1) + fi + + # Fallback: try to find by the most recently mapped window + if [ -z "$new_addr" ] || [ "$new_addr" = "null" ]; then + new_addr=$(hyprctl clients -j | jq -r 'sort_by(.focusHistoryID) | .[-1] | .address') + fi + + if [ -n "$new_addr" ] && [ "$new_addr" != "null" ]; then + # Store the address + echo "$new_addr" > "$ADDR_FILE" + debug_echo "Terminal created with address: $new_addr in special workspace" + + # Small delay to ensure it's properly in special workspace + sleep 0.2 + + # Now bring it back with the same animation as subsequent shows + # Use movetoworkspacesilent to avoid affecting workspace history + hyprctl dispatch movetoworkspacesilent "$CURRENT_WS,address:$new_addr" + hyprctl dispatch pin "address:$new_addr" + animate_slide_down "$new_addr" "$target_x" "$target_y" "$width" "$height" + + return 0 + fi + + debug_echo "Failed to get terminal address" + return 1 +} + +# Main logic +if terminal_exists; then + TERMINAL_ADDR=$(get_terminal_address) + debug_echo "Found existing terminal: $TERMINAL_ADDR" + + if terminal_in_special; then + debug_echo "Bringing terminal from scratchpad with slide down animation" + + # Calculate target position + pos_info=$(calculate_dropdown_position) + target_x=$(echo $pos_info | cut -d' ' -f1) + target_y=$(echo $pos_info | cut -d' ' -f2) + width=$(echo $pos_info | cut -d' ' -f3) + height=$(echo $pos_info | cut -d' ' -f4) + + # Use movetoworkspacesilent to avoid affecting workspace history + hyprctl dispatch movetoworkspacesilent "$CURRENT_WS,address:$TERMINAL_ADDR" + hyprctl dispatch pin "address:$TERMINAL_ADDR" + + # Set size and animate slide down + hyprctl dispatch resizewindowpixel "exact $width $height,address:$TERMINAL_ADDR" + animate_slide_down "$TERMINAL_ADDR" "$target_x" "$target_y" "$width" "$height" + + hyprctl dispatch focuswindow "address:$TERMINAL_ADDR" + else + debug_echo "Hiding terminal to scratchpad with slide up animation" + + # Get current geometry for animation + geometry=$(get_window_geometry "$TERMINAL_ADDR") + if [ -n "$geometry" ]; then + curr_x=$(echo $geometry | cut -d' ' -f1) + curr_y=$(echo $geometry | cut -d' ' -f2) + curr_width=$(echo $geometry | cut -d' ' -f3) + curr_height=$(echo $geometry | cut -d' ' -f4) + + debug_echo "Current geometry: ${curr_x},${curr_y} ${curr_width}x${curr_height}" + + # Animate slide up first + animate_slide_up "$TERMINAL_ADDR" "$curr_x" "$curr_y" "$curr_width" "$curr_height" + + # Small delay then move to special workspace and unpin + sleep 0.1 + hyprctl dispatch pin "address:$TERMINAL_ADDR" # Unpin (toggle) + hyprctl dispatch movetoworkspacesilent "$SPECIAL_WS,address:$TERMINAL_ADDR" + else + debug_echo "Could not get window geometry, moving to scratchpad without animation" + hyprctl dispatch pin "address:$TERMINAL_ADDR" + hyprctl dispatch movetoworkspacesilent "$SPECIAL_WS,address:$TERMINAL_ADDR" + fi + fi +else + debug_echo "No existing terminal found, creating new one" + if spawn_terminal; then + TERMINAL_ADDR=$(get_terminal_address) + if [ -n "$TERMINAL_ADDR" ]; then + hyprctl dispatch focuswindow "address:$TERMINAL_ADDR" + fi + fi +fi
\ No newline at end of file diff --git a/config/hypr/scripts/Refresh.sh b/config/hypr/scripts/Refresh.sh index 2d7887a5..d04570b1 100755 --- a/config/hypr/scripts/Refresh.sh +++ b/config/hypr/scripts/Refresh.sh @@ -25,8 +25,8 @@ done # added since wallust sometimes not applying killall -SIGUSR2 waybar -# quit ags & relaunch ags -#ags -q && ags & +# quit quickshell & relaunch quickshell +#pkill qs && qs & # some process to kill for pid in $(pidof waybar rofi swaync ags swaybg); do diff --git a/config/hypr/scripts/RefreshNoWaybar.sh b/config/hypr/scripts/RefreshNoWaybar.sh index e5a0835e..cdbb82db 100755 --- a/config/hypr/scripts/RefreshNoWaybar.sh +++ b/config/hypr/scripts/RefreshNoWaybar.sh @@ -26,7 +26,7 @@ for _prs in "${_ps[@]}"; do done # quit ags & relaunch ags -#ags -q && ags & +#pkill qs && qs & # Wallust refresh ${SCRIPTSDIR}/WallustSwww.sh & diff --git a/config/hypr/scripts/RofiThemeSelector.sh b/config/hypr/scripts/RofiThemeSelector.sh index 6fd8a6f8..8b2fcb71 100755 --- a/config/hypr/scripts/RofiThemeSelector.sh +++ b/config/hypr/scripts/RofiThemeSelector.sh @@ -1,75 +1,154 @@ #!/bin/bash -# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## -# Script for adding a selected theme to the Rofi config +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ # +# Rofi Themes - Script to preview and apply themes by live-reloading the config. -IFS=$'\n\t' +# --- Configuration --- +ROFI_THEMES_DIR_CONFIG="$HOME/.config/rofi/themes" +ROFI_THEMES_DIR_LOCAL="$HOME/.local/share/rofi/themes" +ROFI_CONFIG_FILE="$HOME/.config/rofi/config.rasi" +ROFI_THEME_FOR_THIS_SCRIPT="$HOME/.config/rofi/config-rofi-theme.rasi" # A separate rofi theme for the picker itself +IDIR="$HOME/.config/swaync/images" # For notifications -# Define directories and variables -rofi_theme_dir="$HOME/.config/rofi/themes" -rofi_config_file="$HOME/.config/rofi/config.rasi" -SED=$(which sed) -iDIR="$HOME/.config/swaync/images" -rofi_theme="$HOME/.config/rofi/config-rofi-theme.rasi" +# --- Helper Functions --- -# Function to display menu options -menu() { - options=() - while IFS= read -r file; do - options+=("$file") - done < <(find -L "$rofi_theme_dir" -maxdepth 1 -type f -exec basename {} \; | sort -V) - - printf '%s\n' "${options[@]}" +# Function to send a notification +notify_user() { + notify-send -u low -i "$1" "$2" "$3" } -# Function to add or update theme in the config.rasi -add_theme_to_config() { - local theme_name="$1" - local theme_path="$rofi_theme_dir/$theme_name" - - # if config in $HOME to write as $HOME - if [[ "$theme_path" == $HOME/* ]]; then - theme_path_with_tilde="~${theme_path#$HOME}" - else - theme_path_with_tilde="$theme_path" - fi +# Function to apply the selected rofi theme to the main config file +apply_rofi_theme_to_config() { + local theme_name_to_apply="$1" - # If no @theme is in the file, add it - if ! grep -q '^\s*@theme' "$rofi_config_file"; then - echo -e "\n\n@theme \"$theme_path_with_tilde\"" >> "$rofi_config_file" - echo "Added @theme \"$theme_path_with_tilde\" to $rofi_config_file" - else - $SED -i "s/^\(\s*@theme.*\)/\/\/\1/" "$rofi_config_file" - echo -e "@theme \"$theme_path_with_tilde\"" >> "$rofi_config_file" - echo "Updated @theme line to $theme_path_with_tilde" - fi + # Find the full path of the theme file + local theme_path + if [[ -f "$ROFI_THEMES_DIR_CONFIG/$theme_name_to_apply" ]]; then + theme_path="$ROFI_THEMES_DIR_CONFIG/$theme_name_to_apply" + elif [[ -f "$ROFI_THEMES_DIR_LOCAL/$theme_name_to_apply" ]]; then + theme_path="$ROFI_THEMES_DIR_LOCAL/$theme_name_to_apply" + else + notify_user "$IDIR/error.png" "Error" "Theme file not found: $theme_name_to_apply" + return 1 + fi - # Ensure no more than max # of lines with //@theme lines - max_line="9" - total_lines=$(grep -c '^\s*//@theme' "$rofi_config_file") + # Use ~ for the home directory in the config path + local theme_path_with_tilde="~${theme_path#$HOME}" - if [ "$total_lines" -gt "$max_line" ]; then - excess=$((total_lines - max_line)) - # Remove the oldest or the very top //@theme lines - for i in $(seq 1 "$excess"); do - $SED -i '0,/^\s*\/\/@theme/ { /^\s*\/\/@theme/ {d; q; }}' "$rofi_config_file" - done - echo "Removed excess //@theme lines" - fi -} + # Create a temporary file to safely edit the config + local temp_rofi_config_file + temp_rofi_config_file=$(mktemp) + cp "$ROFI_CONFIG_FILE" "$temp_rofi_config_file" -# Main function -main() { - choice=$(menu | rofi rofi -dmenu -i -config $rofi_theme) + # Comment out any existing @theme entry + sed -i -E 's/^(\s*@theme)/\\/\\/\1/' "$temp_rofi_config_file" - if [[ -z "$choice" ]]; then - exit 0 - fi - add_theme_to_config "$choice" - notify-send -i "$iDIR/ja.png" -u low 'Rofi Theme applied:' "$choice" + # Add the new @theme entry at the end of the file + echo "@theme \"$theme_path_with_tilde\"" >>"$temp_rofi_config_file" + + # Overwrite the original config file + cp "$temp_rofi_config_file" "$ROFI_CONFIG_FILE" + rm "$temp_rofi_config_file" + + # Prune old commented-out theme lines to prevent clutter + local max_lines=10 + local total_lines=$(grep -c '^//\s*@theme' "$ROFI_CONFIG_FILE") + if [ "$total_lines" -gt "$max_lines" ]; then + local excess=$((total_lines - max_lines)) + for ((i = 1; i <= excess; i++)); do + sed -i '0,/^\s*\/\/@theme/s///' "$ROFI_CONFIG_FILE" + done + fi + + return 0 } -if pgrep -x "rofi" >/dev/null; then - pkill rofi +# --- Main Script Execution --- + +# Check for required directories and files +if [ ! -d "$ROFI_THEMES_DIR_CONFIG" ] && [ ! -d "$ROFI_THEMES_DIR_LOCAL" ]; then + notify_user "$IDIR/error.png" "E-R-R-O-R" "No Rofi themes directory found." + exit 1 +fi + +if [ ! -f "$ROFI_CONFIG_FILE" ]; then + notify_user "$IDIR/error.png" "E-R-R-O-R" "Rofi config file not found: $ROFI_CONFIG_FILE" + exit 1 +fi + +# Backup the original config content +original_rofi_config_content_backup=$(cat "$ROFI_CONFIG_FILE") + +# Generate a sorted list of available theme file names +mapfile -t available_theme_names < <(( + find "$ROFI_THEMES_DIR_CONFIG" -maxdepth 1 -name "*.rasi" -type f -printf "%f\n" 2>/dev/null + find "$ROFI_THEMES_DIR_LOCAL" -maxdepth 1 -name "*.rasi" -type f -printf "%f\n" 2>/dev/null +) | sort -V -u) + +if [ ${#available_theme_names[@]} -eq 0 ]; then + notify_user "$IDIR/error.png" "No Rofi Themes" "No .rasi files found in theme directories." + exit 1 fi -main +# Find the currently active theme to set as the initial selection +current_selection_index=0 +current_active_theme_path=$(grep -oP '^\s*@theme\s*"\K[^"]+' "$ROFI_CONFIG_FILE" | tail -n 1) +if [ -n "$current_active_theme_path" ]; then + current_active_theme_name=$(basename "$current_active_theme_path") + for i in "${!available_theme_names[@]}"; do + if [[ "${available_theme_names[$i]}" == "$current_active_theme_name" ]]; then + current_selection_index=$i + break + fi + done +fi + +# Main preview loop +while true; do + theme_to_preview_now="${available_theme_names[$current_selection_index]}" + + # Apply the theme for preview + if ! apply_rofi_theme_to_config "$theme_to_preview_now"; then + echo "$original_rofi_config_content_backup" >"$ROFI_CONFIG_FILE" + notify_user "$IDIR/error.png" "Preview Error" "Failed to apply $theme_to_preview_now. Reverted." + exit 1 + fi + + # Prepare theme list for Rofi + rofi_input_list="" + for theme_name_in_list in "${available_theme_names[@]}"; do + rofi_input_list+="$(basename "$theme_name_in_list" .rasi)\n" + done + rofi_input_list_trimmed="${rofi_input_list%\\n}" + + # Launch Rofi and get user's choice + chosen_index_from_rofi=$(echo -e "$rofi_input_list_trimmed" | + rofi -dmenu -i \ + -format 'i' \ + -p "Rofi Theme" \ + -mesg "‼️ **note** ‼️ Enter: Preview || Ctrl+S: Apply & Exit || Esc: Cancel" \ + -config "$ROFI_THEME_FOR_THIS_SCRIPT" \ + -selected-row "$current_selection_index" \ + -kb-custom-1 "Control+s") + + rofi_exit_code=$? + + # Handle Rofi's exit code + if [ $rofi_exit_code -eq 0 ]; then # Enter + if [[ "$chosen_index_from_rofi" =~ ^[0-9]+$ ]] && [ "$chosen_index_from_rofi" -lt "${#available_theme_names[@]}" ]; then + current_selection_index="$chosen_index_from_rofi" + fi + elif [ $rofi_exit_code -eq 1 ]; then # Escape + notify_user "$IDIR/note.png" "Rofi Theme" "Selection cancelled. Reverting to original theme." + echo "$original_rofi_config_content_backup" >"$ROFI_CONFIG_FILE" + break + elif [ $rofi_exit_code -eq 10 ]; then # Custom bind 1 (Ctrl+S) + notify_user "$IDIR/ja.png" "Rofi Theme Applied" "$(basename "$theme_to_preview_now" .rasi)" + break + else # Error or unexpected exit code + notify_user "$IDIR/error.png" "Rofi Error" "Unexpected Rofi exit ($rofi_exit_code). Reverting." + echo "$original_rofi_config_content_backup" >"$ROFI_CONFIG_FILE" + break + fi +done + +exit 0 diff --git a/config/hypr/scripts/Volume.sh b/config/hypr/scripts/Volume.sh index b205f8f9..8efdb55c 100755 --- a/config/hypr/scripts/Volume.sh +++ b/config/hypr/scripts/Volume.sh @@ -32,9 +32,9 @@ get_icon() { # Notify 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" + notify-send -e -h string:x-canonical-private-synchronous:volume_notif -h boolean:SWAYNC_BYPASS_DND:true -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 Level:" " $(get_volume)" && + notify-send -e -h int:value:"$(get_volume | sed 's/%//')" -h string:x-canonical-private-synchronous:volume_notif -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$(get_icon)" " Volume Level:" " $(get_volume)" && "$sDIR/Sounds.sh" --volume fi } @@ -60,18 +60,18 @@ dec_volume() { # Toggle Mute toggle_mute() { if [ "$(pamixer --get-mute)" == "false" ]; then - pamixer -m && notify-send -e -u low -i "$iDIR/volume-mute.png" " Mute" + pamixer -m && notify-send -e -u low -h boolean:SWAYNC_BYPASS_DND:true -i "$iDIR/volume-mute.png" " Mute" elif [ "$(pamixer --get-mute)" == "true" ]; then - pamixer -u && notify-send -e -u low -i "$(get_icon)" " Volume:" " Switched ON" + pamixer -u && notify-send -e -u low -h boolean:SWAYNC_BYPASS_DND:true -i "$(get_icon)" " Volume:" " Switched ON" fi } # Toggle Mic 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" + pamixer --default-source -m && notify-send -e -u low -h boolean:SWAYNC_BYPASS_DND:true -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" + pamixer -u --default-source u && notify-send -e -u low -h boolean:SWAYNC_BYPASS_DND:true -i "$iDIR/microphone.png" " Microphone:" " Switched ON" fi } # Get Mic Icon @@ -98,7 +98,7 @@ get_mic_volume() { 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" + notify-send -e -h int:value:"$volume" -h "string:x-canonical-private-synchronous:volume_notif" -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$icon" " Mic Level:" " $volume" } # Increase MIC Volume diff --git a/config/hypr/scripts/WaybarLayout.sh b/config/hypr/scripts/WaybarLayout.sh index 955432fc..b4d9c493 100755 --- a/config/hypr/scripts/WaybarLayout.sh +++ b/config/hypr/scripts/WaybarLayout.sh @@ -29,9 +29,10 @@ main() { # Mark and locate the active layout default_row=0 + MARKER="👉" for i in "${!options[@]}"; do if [[ "${options[i]}" == "$current_name" ]]; then - options[i]="👉 ${options[i]}" + options[i]="$MARKER ${options[i]}" default_row=$i break fi @@ -49,7 +50,7 @@ main() { [[ -z "$choice" ]] && { echo "No option selected. Exiting."; exit 0; } # Strip marker before applying - choice=${choice% ⮕} + choice=${choice# $MARKER} case "$choice" in "no panel") diff --git a/config/hypr/scripts/WaybarStyles.sh b/config/hypr/scripts/WaybarStyles.sh index 20f0873b..a439f8eb 100755 --- a/config/hypr/scripts/WaybarStyles.sh +++ b/config/hypr/scripts/WaybarStyles.sh @@ -31,9 +31,10 @@ main() { # mark the active style and record its index default_row=0 + MARKER="👉" for i in "${!options[@]}"; do if [[ "${options[i]}" == "$current_name" ]]; then - options[i]="👉 ${options[i]}" + options[i]="$MARKER ${options[i]}" default_row=$i break fi @@ -50,7 +51,7 @@ main() { [[ -z "$choice" ]] && { echo "No option selected. Exiting."; exit 0; } # remove annotation and apply - choice=${choice% ⮕} + choice=${choice# $MARKER} apply_style "$choice" } diff --git a/config/hypr/scripts/sddm_wallpaper-v2.sh b/config/hypr/scripts/sddm_wallpaper-v2.sh new file mode 100644 index 00000000..a781156e --- /dev/null +++ b/config/hypr/scripts/sddm_wallpaper-v2.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ +# SDDM Wallpaper and Wallust Colors Setter + +# for the upcoming changes on the simple_sddm_theme + +# variables +terminal=kitty +wallDIR="$HOME/Pictures/wallpapers" +SCRIPTSDIR="$HOME/.config/hypr/scripts" +wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" +wallpaper_modified="$HOME/.config/hypr/wallpaper_effects/.wallpaper_modified" +sddm_simple="/usr/share/sddm/themes/simple_sddm_2" + +# rofi-wallust-sddm colors path +rofi_wallust="$HOME/.config/rofi/wallust/colors-rofi.rasi" +sddm_theme_conf="$sddm_simple/theme.conf" + +# Directory for swaync +iDIR="$HOME/.config/swaync/images" +iDIRi="$HOME/.config/swaync/icons" + +# Parse arguments +mode="effects" # default +if [[ "$1" == "--normal" ]]; then + mode="normal" +elif [[ "$1" == "--effects" ]]; then + mode="effects" +fi + +# Extract colors from rofi wallust config + +color0=$(grep -oP 'color1:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +color1=$(grep -oP 'color0:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +color7=$(grep -oP 'color14:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +color10=$(grep -oP 'color10:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +color12=$(grep -oP 'color12:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +color13=$(grep -oP 'color13:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +foreground=$(grep -oP 'foreground:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +#background-color=$(grep -oP 'background:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") + +# wallpaper to use +if [[ "$mode" == "normal" ]]; then + wallpaper_path="$wallpaper_current" +else + wallpaper_path="$wallpaper_modified" +fi + +# Launch terminal and apply changes +$terminal -e bash -c " +echo 'Enter your password to update SDDM wallpapers and colors'; + +# Update the colors in the SDDM config +sudo sed -i \"s/HeaderTextColor=\\\"#.*\\\"/HeaderTextColor=\\\"$color13\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/DateTextColor=\\\"#.*\\\"/DateTextColor=\\\"$color13\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/TimeTextColor=\\\"#.*\\\"/TimeTextColor=\\\"$color13\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/DropdownSelectedBackgroundColor=\\\"#.*\\\"/DropdownSelectedBackgroundColor=\\\"$color13\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/SystemButtonsIconsColor=\\\"#.*\\\"/SystemButtonsIconsColor=\\\"$color13\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/SessionButtonTextColor=\\\"#.*\\\"/SessionButtonTextColor=\\\"$color13\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/VirtualKeyboardButtonTextColor=\\\"#.*\\\"/VirtualKeyboardButtonTextColor=\\\"$color13\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/HighlightBackgroundColor=\\\"#.*\\\"/HighlightBackgroundColor=\\\"$color12\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/LoginFieldTextColor=\\\"#.*\\\"/LoginFieldTextColor=\\\"$color12\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/PasswordFieldTextColor=\\\"#.*\\\"/PasswordFieldTextColor=\\\"$color12\\\"/\" \"$sddm_theme_conf\" + +sudo sed -i \"s/DropdownBackgroundColor=\\\"#.*\\\"/DropdownBackgroundColor=\\\"$color1\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/HighlightTextColor=\\\"#.*\\\"/HighlightTextColor=\\\"$color10\\\"/\" \"$sddm_theme_conf\" + +sudo sed -i \"s/PlaceholderTextColor=\\\"#.*\\\"/PlaceholderTextColor=\\\"$color7\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/UserIconColor=\\\"#.*\\\"/UserIconColor=\\\"$color7\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/PasswordIconColor=\\\"#.*\\\"/PasswordIconColor=\\\"$color7\\\"/\" \"$sddm_theme_conf\" + +# Copy wallpaper to SDDM theme +sudo cp \"$wallpaper_path\" \"$sddm_simple/Backgrounds/default\" + +notify-send -i \"$iDIR/ja.png\" \"SDDM\" \"Background SET\" +"
\ No newline at end of file diff --git a/config/hypr/scripts/sddm_wallpaper.sh b/config/hypr/scripts/sddm_wallpaper.sh new file mode 100755 index 00000000..fd385fcd --- /dev/null +++ b/config/hypr/scripts/sddm_wallpaper.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ +# SDDM Wallpaper and Wallust Colors Setter + +# variables +terminal=kitty +wallDIR="$HOME/Pictures/wallpapers" +SCRIPTSDIR="$HOME/.config/hypr/scripts" +wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" +wallpaper_modified="$HOME/.config/hypr/wallpaper_effects/.wallpaper_modified" +sddm_simple="/usr/share/sddm/themes/simple_sddm_2" + +# rofi-wallust-sddm colors path +rofi_wallust="$HOME/.config/rofi/wallust/colors-rofi.rasi" +sddm_theme_conf="$sddm_simple/theme.conf" + +# Directory for swaync +iDIR="$HOME/.config/swaync/images" +iDIRi="$HOME/.config/swaync/icons" + +# Parse arguments +mode="effects" # default +if [[ "$1" == "--normal" ]]; then + mode="normal" +elif [[ "$1" == "--effects" ]]; then + mode="effects" +fi + +# Extract colors from rofi wallust config +main_color=$(grep -oP 'color13:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +accent_color=$(grep -oP 'color12:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +bg_color=$(grep -oP 'color0:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +placeholder_color="$accent_color" +icon_color=$(grep -oP 'foreground:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") + +# wallpaper to use +if [[ "$mode" == "normal" ]]; then + wallpaper_path="$wallpaper_current" +else + wallpaper_path="$wallpaper_modified" +fi + +# Launch terminal and apply changes +$terminal -e bash -c " +echo 'Enter your password to update SDDM wallpapers and colors'; +sudo sed -i \"s/MainColor=\\\"#.*\\\"/MainColor=\\\"$main_color\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/AccentColor=\\\"#.*\\\"/AccentColor=\\\"$accent_color\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/BackgroundColor=\\\"#.*\\\"/BackgroundColor=\\\"$bg_color\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/placeholderColor=\\\"#.*\\\"/placeholderColor=\\\"$placeholder_color\\\"/\" \"$sddm_theme_conf\" +sudo sed -i \"s/IconColor=\\\"#.*\\\"/IconColor=\\\"$icon_color\\\"/\" \"$sddm_theme_conf\" + +# Copy wallpaper +sudo cp \"$wallpaper_path\" \"$sddm_simple/Backgrounds/default\" + +notify-send -i \"$iDIR/ja.png\" \"SDDM\" \"Background SET\" +" |
