Browse Source

Sync: 2025-10-26 18:14:32

Gabriel Capella 4 ngày trước cách đây
mục cha
commit
6659266f1b

+ 1 - 1
dots/.config/fish/fish_variables

@@ -30,7 +30,7 @@ SETUVAR fish_color_user:brgreen
 SETUVAR fish_color_valid_path:\x2d\x2dunderline
 SETUVAR fish_greeting:Capella
 SETUVAR fish_key_bindings:fish_vi_key_bindings
-SETUVAR fish_most_recent_dir:/home/capella/\x2edofiles/dotfiles
+SETUVAR fish_most_recent_dir:/home/capella
 SETUVAR fish_pager_color_completion:\x1d
 SETUVAR fish_pager_color_description:B3A06D\x1eyellow
 SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline

+ 2 - 1
dots/.config/sway/config

@@ -176,10 +176,11 @@ bindsym XF86AudioPause exec playerctl play-pause
 bindsym XF86AudioNext exec playerctl next
 bindsym XF86AudioPrev exec playerctl previous
 
-# Monitor
+# Monitor (External)
 bindsym XF86MonBrightnessUp exec ddcutil setvcp --sn 6L1M413 10 + 5
 bindsym XF86MonBrightnessDown exec ddcutil setvcp --sn 6L1M413 10 - 5
 
+bindsym $mod+b exec ~/.config/sway/scripts/brightness-slider.sh
 
 # Audio
 bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%

+ 53 - 0
dots/.config/sway/scripts/brightness-slider.sh

@@ -0,0 +1,53 @@
+#!/bin/bash
+# Brightness slider for external monitor using ddcutil
+
+# Monitor configuration
+MONITOR_SERIAL="6L1M413"
+VCP_CODE=10
+
+# Get current brightness (VCP code 10)
+current_output=$(ddcutil getvcp --sn "$MONITOR_SERIAL" "$VCP_CODE" 2>/dev/null)
+
+if [ $? -ne 0 ] || [ -z "$current_output" ]; then
+    echo "Error: Could not communicate with monitor $MONITOR_SERIAL" >&2
+    exit 1
+fi
+
+# Parse current brightness from output like "VCP code 0x10 (Brightness): current value = 50, max value = 100"
+current_percent=$(echo "$current_output" | grep -oP 'current value\s*=\s*\K\d+')
+
+if [ -z "$current_percent" ]; then
+    echo "Error: Could not parse brightness value" >&2
+    exit 1
+fi
+
+# Round to nearest 5
+current_percent=$(((current_percent + 2) / 5 * 5))
+
+# Generate brightness levels
+levels=""
+for i in {0..100..5}; do
+    if [ "$i" -eq "$current_percent" ]; then
+        levels+="● $i%\n"
+    else
+        levels+="  $i%\n"
+    fi
+done
+
+# Show menu and get selection
+selected=$(echo -e "$levels" | bemenu -l 15 -p "󰃞 Monitor Brightness" --counter always -c -W 0.2 -B 10 \
+    --fixed-height --fn 'B612 11' \
+    --bdr "#323232" --tf "#FFFFFF" --hf "#FFFFFF")
+
+# Exit if nothing selected
+if [ -z "$selected" ]; then
+    exit 0
+fi
+
+# Extract percentage from selection
+percent=$(echo "$selected" | grep -oP '\d+(?=%)')
+
+# Set brightness
+if [ -n "$percent" ]; then
+    ddcutil setvcp --sn "$MONITOR_SERIAL" "$VCP_CODE" "$percent"
+fi

+ 24 - 0
dots/.config/sway/scripts/get-monitor-brightness.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+# Get current monitor brightness for waybar
+
+MONITOR_SERIAL="6L1M413"
+VCP_CODE=10
+
+# Get current brightness
+current_output=$(ddcutil getvcp --sn "$MONITOR_SERIAL" "$VCP_CODE" 2>/dev/null)
+
+if [ $? -ne 0 ]; then
+    echo '{"text": "N/A", "tooltip": "Monitor not available"}'
+    exit 0
+fi
+
+# Parse current brightness
+current=$(echo "$current_output" | grep -oP 'current value\s*=\s*\K\d+')
+
+if [ -z "$current" ]; then
+    echo '{"text": "N/A", "tooltip": "Could not read brightness"}'
+    exit 0
+fi
+
+# Output JSON for waybar
+echo "{\"text\": \"$current%\", \"tooltip\": \"Monitor Brightness: $current%\"}"

+ 13 - 0
dots/.config/waybar/config

@@ -26,6 +26,7 @@
         "sway/window"
     ],
     "modules-right": [
+        "custom/brightness",
         "pulseaudio",
         "network",
         "memory",
@@ -41,6 +42,18 @@
     // Modules
     // -------------------------------------------------------------------------
 
+    "custom/brightness": {
+        "exec": "~/.config/sway/scripts/get-monitor-brightness.sh",
+        "return-type": "json",
+        "interval": 2,
+        "on-click": "~/.config/sway/scripts/brightness-slider.sh",
+        "on-scroll-up": "ddcutil setvcp --sn 6L1M413 10 + 5 && pkill -RTMIN+8 waybar",
+        "on-scroll-down": "ddcutil setvcp --sn 6L1M413 10 - 5 && pkill -RTMIN+8 waybar",
+        "signal": 8,
+        "format": "🖵  {}",
+        "smooth-scrolling-threshold": 1
+    },
+
     "battery": {
         "interval": 10,
         "states": {

+ 10 - 1
dots/.config/waybar/style.css

@@ -58,6 +58,7 @@
 #battery,
 #clock,
 #cpu,
+#custom-brightness,
 #custom-keyboard-layout,
 #memory,
 #mode,
@@ -66,7 +67,7 @@
 #temperature {
     padding-left: 10px;
     padding-right: 10px;
-    min-width: 70px;
+    min-width: 60px;
 }
 
 
@@ -74,6 +75,14 @@
  * Module styles
  * -------------------------------------------------------------------------- */
 
+#custom-brightness {
+    /* No styles */
+}
+
+#custom-brightness:hover {
+    background-color: #404040;
+}
+
 #battery {
     animation-timing-function: linear;
     animation-iteration-count: infinite;