Commit 62b4a86

Ansari <ping@ansari.wtf>
2025-07-20 09:46:40
Introducing wraith
1 parent 33a4599
.config/hypr/modules/keybinds.conf
@@ -14,6 +14,7 @@ bind = $mainMod, SPACE, exec, $menu
 bind = $mainMod, f, togglefloating,s
 bind = $mainMod, P, pseudo, # dwindle
 bind = $mainMod, J, togglesplit, # dwindle
+bind = $mainMod, R, exec, hyprpanel -q && hyprpanel
 
 # TODOS
 # Example special workspace (scratchpad)
@@ -21,7 +22,7 @@ bind = $mainMod, J, togglesplit, # dwindle
 # bind = $mainMod SHIFT, S, movetoworkspace, special:magic
 
 #CUSTOM SCRIPTS
-bind = $mainMod, S, exec, $HOME/.scripts/screenshot.sh
+bind = $mainMod, S, exec, $HOME/.wraith/scripts/screenshot.sh
 
 # Move focus with mainMod + arrow keys
 bind = $mainMod, left, movefocus, l
.config/hyprpanel/config.json
@@ -4,7 +4,13 @@
     "*": {
       "left": ["workspaces", "clock"],
       "middle": ["media"],
-      "right": ["volume", "systray", "notifications", "power"]
+      "right": [
+        "volume",
+        "custom/brightness",
+        "systray",
+        "notifications",
+        "power"
+      ]
     }
   },
   "theme.bar.floating": false,
.config/hyprpanel/modules.json
@@ -0,0 +1,18 @@
+{
+  "custom/brightness": {
+    "icon": ["󰃞", "󰃟", "󰃠"],
+    "label": "{percentage}%",
+    "tooltip": "Brightness: {percentage}%\nScroll to adjust, Click to reset",
+    "truncationSize": -1,
+    "execute": "$HOME/.wraith/scripts/brightness.sh get",
+    "executeOnAction": "$HOME/.wraith/scripts/brightness.sh get",
+    "interval": 1000,
+    "hideOnEmpty": false,
+    "scrollThreshold": 2,
+    "actions": {
+      "onScrollUp": "$HOME/.wraith/scripts/brightness.sh set +5",
+      "onScrollDown": "$HOME/.wraith/scripts/brightness.sh set -5",
+      "onMiddleClick": "$HOME/.wraith/scripts/brightness.sh set 10"
+    }
+  }
+}
\ No newline at end of file
.config/hyprpanel/modules.scss
@@ -0,0 +1,12 @@
+@include styleModule(
+  'cmodule-brightness',
+  (
+    'text-color': #cba6f7,
+    'icon-color': #242438,
+    'icon-background': #cba6f7,
+    'label-background': #242438,
+    'inner-spacing': 0.5em,
+    'border-enabled': false,
+    'icon-size': 1.2em
+  )
+);
\ No newline at end of file
.config/rofi/config.rasi
@@ -1,1 +1,1 @@
-@theme "./custom-rasi-theme"
+@theme "./wraith-theme"
.config/rofi/custom-rasi-template.rasi → .config/rofi/wraith-template.rasi
File renamed without changes
.config/rofi/custom-rasi-theme.rasi → .config/rofi/wraith-theme.rasi
@@ -18,7 +18,7 @@ configuration{
     fg3:    #4C566A;
 }
 
-@import "./custom-rasi-template.rasi"
+@import "./wraith-template.rasi"
 
 element selected {
     text-color: @bg1;
.oh-my-zsh/custom/themes/custom-gozilla.zsh-theme → .oh-my-zsh/custom/themes/wraith.zsh-theme
File renamed without changes
.scripts/arch-spring-cleanup.sh → .wraith/scripts/arch-spring-cleanup.sh
@@ -27,7 +27,6 @@ LOG_DIR="$HOME/.local/var/log"
 mkdir -p "$LOG_DIR"
 LOG_FILE="$LOG_DIR/spring-clean-$(date +%F_%H-%M-%S).log"
 
-# Settings (you can customize these)
 PACCACHE_RETAIN=2     # Keep only the latest 2 versions of packages
 CACHE_DAYS=30         # Delete ~/.cache files older than 30 days
 JOURNAL_RETAIN="7d"   # Keep only 7 days of system logs
.wraith/scripts/brightness.sh
@@ -0,0 +1,231 @@
+#!/bin/zsh 
+
+STATE_FILE="$HOME/.wraith/states/brightness.state"
+LOCK_FILE="/tmp/brightness.lock"
+DEFAULT_STEP=5
+DEFAULT_FALLBACK=10
+
+set -e #saying that exit script immediately if something goes wrong 
+
+show_usage() {
+    echo "Usage: $0 <command> [value]"
+    echo ""
+    echo "Commands:"
+    echo "  get                   Get current brightness (JSON format)"
+    echo "  set <value>           Set brightness to specific value (0-100)"
+    echo "  set +<value>          Increase brightness by value"
+    echo "  set -<value>          Decrease brightness by value"
+    echo "  set +                 Increase by $DEFAULT_STEP% (default step)"
+    echo "  set -                 Decrease by $DEFAULT_STEP% (default step)"
+    echo ""
+    echo "Examples:"
+    echo "  $0 get"
+    echo "  $0 set 75"
+    echo "  $0 set +10"
+    echo "  $0 set -5"
+    echo "  $0 set +"
+    echo "  $0 set -"
+}
+
+cleanup() {
+    rm -f "$LOCK_FILE"
+}
+
+trap cleanup EXIT 
+
+acquire_lock() {
+    local operation="$1"
+    
+    if [[ -f "$LOCK_FILE" ]]; then
+        # If lock file is older than 10 seconds, remove it (stale lock)
+        if [[ $(($(date +%s) - $(stat -c %Y "$LOCK_FILE" 2>/dev/null || echo 0))) -gt 10 ]]; then
+            rm -f "$LOCK_FILE"
+        else
+            if [[ "$operation" == "set" ]]; then
+                echo "Another brightness operation is in progress..." >&2
+                exit 1
+            else
+                # For get operations, wait briefly then continue
+                sleep 1
+                [[ -f "$LOCK_FILE" ]] && return 1
+            fi
+        fi
+    fi
+    
+    touch "$LOCK_FILE"
+    return 0
+}
+
+init_brightness() {
+    echo "Initializing brightness from monitor..." >&2
+    
+    brightness=$(ddcutil getvcp 10 --brief 2>/dev/null | awk '{print $4}'| sed 's/[^0-9]*//g')
+    if [[ -z "$brightness" ]] || [[ ! "$brightness" =~ ^[0-9]+$ ]]; then
+        echo "Error: ddcutil failed. Install ddcutil" >&2;
+        exit 1;
+    else
+        echo "Initial brightness detected: $brightness%" >&2
+    fi
+    
+    mkdir -p "$(dirname "$STATE_FILE")"
+    echo "$brightness" > "$STATE_FILE"
+    echo "$brightness"
+}
+
+validate_brightness() {
+    local value="$1"
+    
+    if [[ ! "$value" =~ ^[0-9]+$ ]]; then
+        return 1
+    fi
+    
+    if [[ $value -lt 0 || $value -gt 100 ]]; then
+        return 1
+    fi
+    
+    return 0
+}
+
+get_brightness() {
+    if [[ ! -f "$STATE_FILE" ]]; then
+        if ! acquire_lock "get"; then
+            sleep 1
+            if [[ -f "$STATE_FILE" ]]; then
+                brightness=$(cat "$STATE_FILE")
+            else
+                brightness=$(init_brightness)
+            fi
+        else
+            brightness=$(init_brightness)
+        fi
+    else
+      
+        brightness=$(cat "$STATE_FILE" 2>/dev/null)
+
+        if ! validate_brightness "$brightness"; then
+            if acquire_lock "get"; then
+                brightness=$(init_brightness)
+            else
+                echo "Error occured: brightness file state corrupted";
+                exit 1;
+            fi
+        fi
+    fi
+    echo "{\"percentage\": $brightness}"
+}
+
+set_brightness() {
+    local change="$1"
+    
+    if [[ -z "$change" ]]; then
+        echo "Error: No value provided for set command" >&2
+        show_usage
+        exit 1
+    fi
+    
+    if ! acquire_lock "set"; then
+        exit 1
+    fi
+    
+    if [[ ! -f "$STATE_FILE" ]]; then
+        echo "State file doesn't exist, initializing..." >&2
+        init_brightness >/dev/null
+    fi
+    
+    current=$(cat "$STATE_FILE" 2>/dev/null)
+    if ! validate_brightness "$current"; then
+        current= $DEFAULT_FALLBACK
+        echo "Warning: Invalid state file, using fallback value: $DEFAULT_FALLBACK%" >&2
+    fi
+    
+    local new_brightness
+    if [[ "$change" == "+" ]]; then
+        new_brightness=$((current + DEFAULT_STEP))
+    elif [[ "$change" == "-" ]]; then
+        new_brightness=$((current - DEFAULT_STEP))
+    elif [[ "$change" == +* ]]; then
+        local step="${change:1}"
+        if [[ "$step" =~ ^[0-9]+$ ]]; then
+            new_brightness=$((current + step))
+        else
+            echo "Error: Invalid increment value: $change" >&2
+            exit 1
+        fi
+    elif [[ "$change" == -* ]]; then
+        local step="${change:1}"
+        if [[ "$step" =~ ^[0-9]+$ ]]; then
+            new_brightness=$((current - step))
+        else
+            echo "Error: Invalid decrement value: $change" >&2
+            exit 1
+        fi
+    elif [[ "$change" =~ ^[0-9]+$ ]]; then
+        new_brightness="$change"
+    else
+        echo "Error: Invalid argument: $change" >&2
+        show_usage
+        exit 1
+    fi
+    
+    if [[ $new_brightness -lt 0 ]]; then
+        new_brightness=0
+    elif [[ $new_brightness -gt 100 ]]; then
+        new_brightness=100
+    fi
+    
+    if [[ $new_brightness -eq $current ]]; then
+        echo "Brightness already at $new_brightness%, no change needed" >&2
+        echo "{\"percentage\": $new_brightness}"
+        return 0
+    fi
+    
+    echo "Setting brightness from $current% to $new_brightness%..." >&2
+    
+    if ddcutil setvcp 10 $new_brightness --brief >/dev/null 2>&1; then
+        echo "$new_brightness" > "$STATE_FILE"
+        echo "✓ Brightness set to $new_brightness%" >&2
+        
+        # if command -v notify-send >/dev/null 2>&1; then
+        #     notify-send "Brightness" "$new_brightness%" -t 3000 -h int:value:$new_brightness -h string:synchronous:brightness 2>/dev/null
+        # fi
+
+        echo "{\"percentage\": $new_brightness}"
+    else
+        echo "✗ Failed to set brightness with ddcutil" >&2
+        exit 1
+    fi
+}
+
+# Main script logic
+case "$1" in
+    "get")
+        if [[ $# -ne 1 ]]; then
+            echo "Error: 'get' command takes no arguments" >&2
+            show_usage
+            exit 1
+        fi
+        get_brightness
+        ;;
+    "set")
+        if [[ $# -ne 2 ]]; then
+            echo "Error: 'set' command requires exactly one argument" >&2
+            show_usage
+            exit 1
+        fi
+        set_brightness "$2"
+        ;;
+    "reset")
+        set_brightness "$DEFAULT_FALLBACK"
+        ;;
+    "help"|"-h"|"--help")
+        show_usage
+        ;;
+    "")
+        show_usage
+        exit 1
+        ;;
+    *)
+        echo "Error: Unknown command: $1" >&2
+        exit 1
+        ;;
+esac
\ No newline at end of file
.scripts/screenshot.sh → .wraith/scripts/screenshot.sh
@@ -10,7 +10,7 @@ OPTIONS=(
 )
 
 # Show rofi menu and get selected option
-CHOICE=$(printf "%s\n" "${OPTIONS[@]}" | rofi -dmenu -i -p "Screenshot Menu" -theme $HOME/.scripts/scripts.rofi.rasi -theme-str 'listview {lines:6;}' 2>/dev/null)
+CHOICE=$(printf "%s\n" "${OPTIONS[@]}" | rofi -dmenu -i -p "Screenshot Menu" -theme $HOME/.wraith/theme/scripts.rofi.rasi -theme-str 'listview {lines:6;}' 2>/dev/null)
 
 SCREENSHOT_DIR=$HOME/dev/desktop/screenshots
 mkdir -p "$SCREENSHOT_DIR"  # Ensure directory exists
.scripts/scripts.rofi.rasi → .wraith/theme/scripts.rofi.rasi
@@ -1,4 +1,4 @@
-@import "custom-rasi-theme.rasi"
+@import "wraith-theme.rasi"
 
 mainbox {
     padding:    0px;
.zshrc
@@ -17,7 +17,7 @@ export PATH="$PATH:$BUN_INSTALL/bin:$ANDROID_HOME/platform-tools:$JAVA_HOME:$AND
 # SOURCING
 #--------------------------------------------------------------------------------
 
-ZSH_THEME="custom-gozilla"
+ZSH_THEME="wraith"
 zstyle ':omz:update' mode reminder  # just remind me to update when it's time
 
 plugins=(git zsh-autosuggestions)