Explorar el Código

add wl screenshot and other hyprland binds + add wl notification daemon

Noah Vogt hace 2 días
padre
commit
84ac98cbe1

+ 11 - 5
dot-config/hypr/hyprland.conf

@@ -11,8 +11,8 @@ monitor=,preferred,auto,auto
 # Set programs that you use
 $terminal = wezterm
 $fileManager = nautilus
-$menu = hyprlauncher
-
+$menu = fuzzel
+$browser = chromium
 
 #################
 ### AUTOSTART ###
@@ -23,6 +23,7 @@ $menu = hyprlauncher
 
 exec-once = swww-daemon &
 exec-once = waybar
+exec-once = swaync
 # exec-once = $terminal
 # exec-once = nm-applet &
 # exec-once = waybar & hyprpaper & firefox
@@ -211,7 +212,7 @@ device {
 
 # See https://wiki.hypr.land/Configuring/Keywords/
 $mainMod = SUPER
-bindir = $mainMod, SUPER_L, exec, fuzzel
+bindr = $mainMod, SUPER_L, exec, fuzzel
 
 # Example binds, see https://wiki.hypr.land/Configuring/Binds/ for more
 bind = $mainMod, Return, exec, $terminal
@@ -219,12 +220,17 @@ bind = $mainMod, Q, killactive,
 bind = $mainMod SHIFT, Q, exec, killall Hyprland
 bind = $mainMod, M, exec, command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch exit
 bind = $mainMod, E, exec, $fileManager --new-window
-bind = $mainMod, V, togglefloating,
-bind = $mainMod, R, exec, $menu
+bind = $mainMod SHIFT, F, togglefloating,
 bind = $mainMod, P, pseudo, # dwindle
+bind = $mainMod, V, exec, $browser
 # bind = $mainMod, J, layoutmsg, togglesplit # dwindle
 bind = $mainMod SHIFT, T, exec, ~/.config/hypr/scripts/toggle-theme.sh
 
+# Screenshots
+bind = , Print, exec, ~/.config/hypr/scripts/screenshot.sh area
+bind = $mainMod CTRL, Print, exec, ~/.config/hypr/scripts/screenshot.sh monitor
+bind = $mainMod SHIFT, Print, exec, ~/.config/hypr/scripts/screenshot.sh window
+
 bind = $mainMod ALT, Space, togglefloating,
 
 # Move focus with mainMod + arrow keys

+ 46 - 0
dot-config/hypr/scripts/screenshot.sh

@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# Script to capture screenshots (Wayland)
+
+# Directory for screenshots
+SCREENSHOT_DIR="$HOME/pix/Screenshots"
+mkdir -p "$SCREENSHOT_DIR"
+
+# Filename format
+TIMESTAMP=$(date +"%Y%m%d-%H%M%S")
+FILENAME="Screenshot_${TIMESTAMP}_hyprland.jpg"
+FILE_PATH="${SCREENSHOT_DIR}/${FILENAME}"
+
+# Capture based on argument
+case "$1" in
+area)
+    # Select an area using slurp
+    grim -t jpeg -g "$(slurp)" "$FILE_PATH"
+    ;;
+monitor)
+    # Active monitor
+    MONITOR=$(hyprctl activeworkspace -j | jq -r '.monitor')
+    grim -t jpeg -o "$MONITOR" "$FILE_PATH"
+    ;;
+window)
+    # Active window
+    WINDOW_DATA=$(hyprctl activewindow -j)
+    if [ "$(echo "$WINDOW_DATA" | jq -r '.address')" == "null" ]; then
+        notify-send "Screenshot failed" "No active window found" -u low
+        exit 1
+    fi
+    WINDOW_AT=$(echo "$WINDOW_DATA" | jq -r '.at | join(",")')
+    WINDOW_SIZE=$(echo "$WINDOW_DATA" | jq -r '.size | join("x")')
+    grim -t jpeg -g "${WINDOW_AT} ${WINDOW_SIZE}" "$FILE_PATH"
+    ;;
+*)
+    echo "Usage: $0 {area|monitor|window}"
+    exit 1
+    ;;
+esac
+
+# Check if file was created and copy to clipboard
+if [ -f "$FILE_PATH" ]; then
+    wl-copy -t image/jpeg <"$FILE_PATH"
+    notify-send "Screenshot saved" "$FILENAME" -i "$FILE_PATH"
+fi

+ 9 - 1
dot-config/hypr/scripts/toggle-theme.sh

@@ -1,7 +1,10 @@
-#!/usr/bin/env bash
+#!/bin/bash
+
+# Script to toggle between light / dark mode
 
 # Set this to where Waybar reads its config files
 WAYBAR_DIR="$HOME/.config/waybar"
+SWAYNC_DIR="$HOME/.config/swaync"
 
 CURRENT_SCHEME=$(gsettings get org.gnome.desktop.interface color-scheme)
 
@@ -9,11 +12,13 @@ if [ "$CURRENT_SCHEME" == "'prefer-dark'" ]; then
     gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
     # Copy the light theme to theme.css
     cp "$WAYBAR_DIR/light.css" "$WAYBAR_DIR/theme.css"
+    cp "$SWAYNC_DIR/light.css" "$SWAYNC_DIR/theme.css"
     notify-send "Light Mode" -a "System"
 else
     gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
     # Copy the dark theme to theme.css
     cp "$WAYBAR_DIR/dark.css" "$WAYBAR_DIR/theme.css"
+    cp "$SWAYNC_DIR/dark.css" "$SWAYNC_DIR/theme.css"
     notify-send "Dark Mode" -a "System"
 fi
 
@@ -21,3 +26,6 @@ fi
 killall -SIGUSR2 waybar
 killall -SIGUSR1 nvim
 pkill -SIGHUP wezterm
+
+# Reload SwayNC CSS styling cleanly
+swaync-client -rs

+ 36 - 0
dot-config/swaync/config.json

@@ -0,0 +1,36 @@
+{
+    "$schema": "/etc/xdg/swaync/configSchema.json",
+    "positionX": "right",
+    "positionY": "top",
+    "layer": "overlay",
+    "control-center-layer": "overlay",
+    "layer-shell": true,
+    "cssPriority": "application",
+    "control-center-margin-top": 10,
+    "control-center-margin-bottom": 10,
+    "control-center-margin-right": 20,
+    "control-center-margin-left": 10,
+    "fit-to-screen": false,
+    "notification-2way-tz": true,
+    "notification-drop-shadow": false,
+    "image-visibility": "when-available",
+    "transition-length": 200,
+    "hide-on-clear": false,
+    "hide-on-action": true,
+    "script-fail-notify": true,
+    "widgets": [
+        "title",
+        "dnd",
+        "notifications"
+    ],
+    "widget-config": {
+        "title": {
+            "text": "Notifications",
+            "clear-all-button": true,
+            "button-text": "Clear All"
+        },
+        "dnd": {
+            "text": "Do Not Disturb"
+        }
+    }
+}

+ 8 - 0
dot-config/swaync/dark.css

@@ -0,0 +1,8 @@
+@define-color bg rgba(26, 27, 38, 0.95);
+@define-color bg_module rgba(36, 40, 59, 0.9);
+@define-color text #ffffff;
+@define-color active_text #33ccff;
+@define-color inactive_text #565f89;
+@define-color urgent #f7768e;
+@define-color active_border #33ccff;
+@define-color hover_bg rgba(122, 162, 247, 0.2);

+ 8 - 0
dot-config/swaync/light.css

@@ -0,0 +1,8 @@
+@define-color bg rgba(225, 226, 231, 0.95);
+@define-color bg_module rgba(204, 208, 218, 0.9);
+@define-color text #4c4f69;
+@define-color active_text #1e66f5;
+@define-color inactive_text #8c8fa1;
+@define-color urgent #d20f39;
+@define-color active_border #1e66f5;
+@define-color hover_bg rgba(4, 165, 229, 0.2);

+ 173 - 0
dot-config/swaync/style.css

@@ -0,0 +1,173 @@
+@import url("theme.css");
+
+* {
+    font-family: "JetBrainsMono Nerd Font", sans-serif; /* Adjust to your preferred font */
+    font-weight: bold;
+}
+
+.control-center .notification-row:focus,
+.control-center .notification-row:hover {
+    opacity: 1;
+    background: @hover_bg;
+}
+
+.notification-row {
+    outline: none;
+    margin: 5px;
+    padding: 0;
+}
+
+.notification {
+    background: @bg_module;
+    border-radius: 12px;
+    margin: 0px;
+    box-shadow: none;
+    padding: 2px;
+}
+
+.notification-content {
+    background: transparent;
+    padding: 6px;
+    border-radius: 12px;
+}
+
+.close-button {
+    background: @urgent;
+    color: @text;
+    text-shadow: none;
+    padding: 0;
+    border-radius: 100%;
+    margin-top: 5px;
+    margin-right: 5px;
+    box-shadow: none;
+    border: none;
+    min-width: 24px;
+    min-height: 24px;
+}
+
+.close-button:hover {
+    box-shadow: none;
+    background: @active_border;
+    transition: all 0.15s ease-in-out;
+}
+
+.notification-default-action,
+.notification-action {
+    padding: 4px;
+    margin: 0;
+    box-shadow: none;
+    background: transparent;
+    border: none;
+    color: @text;
+    transition: all 0.15s ease-in-out;
+}
+
+.notification-default-action:hover,
+.notification-action:hover {
+    -gtk-icon-effect: none;
+    background: @hover_bg;
+}
+
+.summary {
+    font-size: 16px;
+    color: @active_text;
+}
+
+.time {
+    font-size: 12px;
+    color: @inactive_text;
+    margin-right: 24px;
+}
+
+.body {
+    font-size: 14px;
+    font-weight: normal;
+    color: @text;
+}
+
+.control-center {
+    background: @bg;
+    color: @text;
+    border-radius: 16px;
+    border: 2px solid @active_border;
+}
+
+.control-center-list {
+    background: transparent;
+}
+
+.control-center-list-placeholder {
+    opacity: 0.5;
+    color: @text;
+}
+
+.control-center-list-placeholder {
+    font-size: 24px;
+}
+
+/* Widgets */
+.widget-title {
+    color: @text;
+    background: @bg_module;
+    padding: 10px;
+    margin: 10px;
+    border-radius: 12px;
+}
+
+.widget-title > button {
+    font-size: 14px;
+    color: @bg_module;
+    background: @text;
+    border-radius: 8px;
+    border: none;
+}
+
+.widget-title > button:hover {
+    background: @active_border;
+    color: @text;
+}
+
+.widget-dnd {
+    color: @text;
+    background: @bg_module;
+    padding: 10px;
+    margin: 10px;
+    border-radius: 12px;
+}
+
+.widget-dnd > switch {
+    font-size: initial;
+    border-radius: 12px;
+    background: @bg;
+    border: none;
+}
+
+.widget-dnd > switch:checked {
+    background: @active_border;
+}
+
+.widget-dnd > switch slider {
+    background: @text;
+    border-radius: 10px;
+}
+
+/* Fix for weird icon backgrounds and rounding */
+.app-icon,
+.image {
+    background-color: transparent;
+    background: transparent;
+    border-radius: 8px; /* You can adjust this value to match your vibe */
+    box-shadow: none;
+    -gtk-icon-shadow: none;
+    margin-right: 16px;
+}
+
+/* Strip unwanted backgrounds from notification containers */
+.control-center .notification-row,
+.control-center .notification-group,
+.notification-group > box {
+    background: transparent;
+    background-color: transparent;
+    box-shadow: none;
+    border: none;
+}

+ 8 - 0
dot-config/swaync/theme.css

@@ -0,0 +1,8 @@
+@define-color bg rgba(225, 226, 231, 0.95);
+@define-color bg_module rgba(204, 208, 218, 0.9);
+@define-color text #4c4f69;
+@define-color active_text #1e66f5;
+@define-color inactive_text #8c8fa1;
+@define-color urgent #d20f39;
+@define-color active_border #1e66f5;
+@define-color hover_bg rgba(4, 165, 229, 0.2);

+ 22 - 1
dot-config/waybar/config.jsonc

@@ -11,7 +11,28 @@
         "hyprland/workspaces"
     ],
     "modules-center": ["clock"],
-    "modules-right": ["network#vpn", "network", "backlight", "battery", "pulseaudio", "bluetooth"],
+    "modules-right": ["network#vpn", "network", "backlight", "battery", "pulseaudio", "bluetooth", "custom/notification"],
+
+    "custom/notification": {
+        "tooltip": false,
+        "format": "{icon}",
+        "format-icons": {
+            "notification": "<span foreground='red'><sup></sup></span>",
+            "none": "",
+            "dnd-notification": "<span foreground='red'><sup></sup></span>",
+            "dnd-none": "",
+            "inhibited-notification": "<span foreground='red'><sup></sup></span>",
+            "inhibited-none": "",
+            "dnd-inhibited-notification": "<span foreground='red'><sup></sup></span>",
+            "dnd-inhibited-none": ""
+        },
+        "return-type": "json",
+        "exec-if": "which swaync-client",
+        "exec": "swaync-client -swb",
+        "on-click": "swaync-client -t -sw",
+        "on-click-right": "swaync-client -d -sw",
+        "escape": true
+    },
 
     "hyprland/workspaces": {
         "format": "{id}",

+ 2 - 1
dot-config/waybar/style.css

@@ -59,7 +59,8 @@ window#waybar {
 #custom-vpn,
 #backlight,
 #battery,
-#bluetooth {
+#bluetooth,
+#custom-notification {
     padding: 0 15px;
     margin: 5px;
     background-color: @bg_module;

+ 1 - 1
local-bin/screenshot → local-bin/x11-screenshot

@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# script to make a screenshot of the full screen area
+# script to make a screenshot of the full screen area (X11)
 
 [ ! -d "$HOME/pix/screenshots" ] && mkdir-p "$HOME/pix/screenshots"
 

+ 1 - 1
local-bin/screenshot-area → local-bin/x11-screenshot-area

@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# script to make a screenshot from the desired selection
+# script to make a screenshot from the desired selection (X11)
 
 [ ! -d "$HOME/dox/screenshots" ] && mkdir -p "$HOME/dox/screenshots"