// This config is in the KDL format: https://kdl.dev
// "/-" comments out the following node.
// Check the wiki for a full description of the configuration:
// https://yalter.github.io/niri/Configuration:-Introduction
input {
    keyboard {

        xkb {
            layout "ch"
            variant "de_mac"
            model "apple"
        }
    }
    touchpad {
        tap
        natural-scroll
   }
    mouse {

    }
    trackpoint {

    }
}
// x11 support for wayland
xwayland-satellite {
    path "xwayland-satellite"
}
environment {
    ELECTRON_OZONE_PLATFORM_HINT "auto"
    ELECTRON_ENABLE_LOGGING "1"
 // GDK_SCALE "1.75"
    // GDK_DPI_SCALE "1"
}
output "eDP-1" {
    mode "2880x1800@59.990"
    scale 1.1
    position x=0 y=0
    focus-at-startup
}
output "eDP-2" {
    mode "2880x1800@59.990"
    scale 1.1
    position x=0 y=0
    focus-at-startup
}
output "eDP-3" {
    mode "2880x1800@59.990"
    scale 1.1
    position x=0 y=0
    focus-at-startup
}
output "DP-4" {
    mode "2560x1440@59.951"
    position x=1645 y=0
    scale 1.1
}
layout {
    gaps 2
    center-focused-column "never"
    preset-column-widths {
        proportion 0.5
        proportion 0.66667
        proportion 0.3333
    }
    default-column-width {
        proportion 0.5
    }
    focus-ring {
        width 2
        active-color "#7daea3"
        inactive-color "#928374"
    }
    border {
        off
        width 4
        active-color "#eba0ac"
        inactive-color "#505050"
        urgent-color "#9b0000"
    }
    shadow {
        softness 30
        spread 5
        offset x=0 y=5
        color "#0007"
    }
    struts {

    }
}

spawn-at-startup "bash" "/mnt/tank/scripts/fix-bitwarden.sh"
spawn-at-startup "waybar" "-c" "/home/liph/.config/niri/waybar-niri/config.jsonc" "-s" "/home/liph/.config/niri/waybar-niri/style.css"
spawn-at-startup "swaync"
// spawn-at-startup "kanshi"
spawn-at-startup "awww-daemon"
spawn-at-startup "xwayland-satellite"
spawn-at-startup "gammastep" "-l" "47.38:8.54" "-t" "6000:4000"
spawn-at-startup "wezterm"
spawn-at-startup "obsidian"
// spawn-at-startup "kanshi"
spawn-at-startup "librewolf"
spawn-at-startup "sh" "-c" "sleep 5 && exec swayidle -w timeout 300 hyprlock timeout 600 'niri msg action power-off-monitors' resume 'niri msg action power-on-monitors' timeout 3600 'systemctl suspend'"

prefer-no-csd
gestures {
    hot-corners {
        off
    }
}

workspace "1"
workspace "2"
workspace "3"
workspace "4"

// Example: block out two password managers from screen capture.
// (This example rule is commented out with a "/-" in front.)
/-window-rule {
match app-id=r#"^org\.keepassxc\.KeePassXC$"#
match app-id=r#"^org\.gnome\.World\.Secrets$"#
block-out-from "screen-capture"
}
window-rule {
  match app-id="Zoom Workplace"
  open-floating true
}
// Wezterm window rules
window-rule {
    match at-startup=true app-id="wezterm"
    open-on-workspace "1"
    open-maximized true
    open-floating false
    // clip-to-geometry true
}
window-rule {
    match at-startup=false app-id="wezterm"
    open-floating false
    // clip-to-geometry true
}
// Obsidian window rules
window-rule {
    match at-startup=true app-id="obsidian"
    open-on-workspace "3"
    open-maximized true
    open-floating false
}
window-rule {
    match app-id="steam_app_4197610"
    open-fullscreen true
}
window-rule {
    match at-startup=false app-id="obsidian"
    open-maximized true
    open-floating false
}
// Librewolf window rules
window-rule {
    match at-startup=true app-id="librewolf"
    open-on-workspace "2"
    open-maximized true
}
window-rule {
    match app-id="librewolf"
    open-maximized true
    clip-to-geometry true
    open-floating false
}
window-rule {
    match app-id="slack"
    open-maximized true
    clip-to-geometry true
    open-on-workspace "4"
    open-floating false
}
window-rule {
    match app-id="tidal-hifi"
    open-maximized true
    clip-to-geometry true
    open-floating false
    open-on-workspace "4"
}
window-rule {
    match app-id="Tor Browser"
    open-maximized true
    clip-to-geometry true
    open-floating false
    open-on-workspace "2"
}
window-rule {
    match app-id="Claude"
    open-on-workspace "4"
    default-column-width {
        proportion 0.6667
    }
    clip-to-geometry true
}
// 2. Specific rule for windows opening at startup
window-rule {
    match app-id="eu.betterbird.Betterbird"
    open-maximized true
    clip-to-geometry true
    open-on-workspace "3"
}

window-rule {
    match app-id="Slack"
    open-maximized true
    clip-to-geometry true
    open-on-workspace "4"
}
window-rule {
    match app-id="floating_btop"
    default-column-width {
        proportion 0.6667
    }
    open-floating true
}
window-rule {
    match app-id="floating_musikcube"
    default-column-width {
        proportion 0.6667
    }
    open-floating true
}
window-rule {
    match app-id="floating_htop"
    default-column-width {
        proportion 0.6667
    }
    open-floating true
}
window-rule {
    match app-id="floating_bluetui"
    default-column-width {
        proportion 0.6667
    }
    open-floating true
}
window-rule {
    match app-id="floating_pulsemixer"
    default-column-width {
        proportion 0.6667
    }
    open-floating true
}
window-rule {
    match app-id="floating_wavemon"
    default-column-width {
        proportion 0.6667
    }
    open-floating true
}
window-rule {
    match app-id="floating_network-tui"
    default-column-width {
        proportion 0.6667
    }
    open-floating true
}
window-rule {
    match app-id="floating_yazi"
    default-column-width {
        proportion 0.6667
    }
    open-floating true
}
window-rule {
    geometry-corner-radius 5
    clip-to-geometry true
}
binds {
    // Mod+Shift+Slash { show-hotkey-overlay; }
    Mod+Mod5+J {
        spawn "hyprlock"
    }
    Mod+Alt+P hotkey-overlay-title="Open Bitwarden" {
        spawn "bitwarden-desktop"
    }
    Mod+Alt+T hotkey-overlay-title="Open Tipp10" {
        spawn "tipp10"
    }
    Mod+Alt+S hotkey-overlay-title="Open Tidal" {
        spawn "tidal-hifi" "--ozone-platform=wayland" "--enable-features=WaylandWindowDecorations"
    }
    Mod+Alt+O hotkey-overlay-title="Open Obsidian" {
        spawn "obsidian"
    }
    Mod+Alt+C hotkey-overlay-title="Open Claude" {
        spawn "claude-desktop"
    }
    Mod+Alt+Z hotkey-overlay-title="Open Librewolf" {
        spawn "librewolf"
    }
    Mod+Alt+Return hotkey-overlay-title="Open Kitty" {
        spawn "wezterm"
    }
    Mod+Alt+Space hotkey-overlay-title="Open Wofi" {
        spawn "wofi" "--show" "drun"
    }
    Mod+Mod5+Q hotkey-overlay-title="Open Htop" {
        spawn "wezterm" "start" "--class" "floating_htop" "-e" "htop"
    }
    Mod+Mod5+W hotkey-overlay-title="Open Btop" {
        spawn "wezterm" "start" "--class" "floating_btop" "-e" "btop"
    }    
    Mod+Mod5+E hotkey-overlay-title="Open Pulsemixer" {
        spawn "wezterm" "start" "--class" "floating_pulsemixer" "-e" "pulsemixer"
    }
    Mod+Mod5+R allow-inhibiting=false hotkey-overlay-title="Open Bluetui"  {
        spawn "wezterm" "start" "--class" "floating_bluetui" "-e" "bluetui"
    }
    Mod+Mod5+T hotkey-overlay-title="Open Wavemon" {
        spawn "wezterm" "start" "--class" "floating_wavemon" "-e" "wavemon"
    }
    Mod+Mod5+Z hotkey-overlay-title="Open network-tui" {
        spawn "wezterm" "start" "--class" "floating_network-tui" "-e" "network-tui"
    }
    Mod+Mod5+U hotkey-overlay-title="Open Musikcube" {
        spawn "wezterm" "start" "--class" "floating_musikcube" "-e" "musikcube"
    }
    Mod+Mod5+Y hotkey-overlay-title="Open Yazi" {
        spawn "wezterm" "start" "--class" "floating_yazi" "-e" "yazi"
    }
    // Brightness Controll
    Mod+Ctrl+0 {
        spawn "sh" "-c" "~/scripts/layer_notify.sh 0"
    }
    Mod+Ctrl+1 {
        spawn "sh" "-c" "~/scripts/layer_notify.sh 1"
    }
    Mod+Ctrl+2 {
        spawn "sh" "-c" "~/scripts/layer_notify.sh 2"
    }
    Mod+Ctrl+3 {
        spawn "sh" "-c" "~/scripts/layer_notify.sh 3"
    }
    // Brightness controls
    Mod+Ctrl+4 {
        spawn "sh" "-c" "~/scripts/niri_br_up.sh"
    }
    Mod+Ctrl+5 {
        spawn "sh" "-c" "~/scripts/niri_br_down.sh"
    }
    Mod+Ctrl+6 {
        spawn "sh" "-c" "~/scripts/niri_br_blue.sh"
    }
    Mod+Ctrl+7 {
        spawn "sh" "-c" "~/scripts/niri_br_reset.sh"
    }
    // Swaync Notifications
    Mod+Ctrl+8 {
        spawn "swaync-client" "-t"
    }
    Super+Alt+S allow-when-locked=true hotkey-overlay-title=null {
        spawn-sh "pkill orca || exec orca"
    }
    XF86AudioRaiseVolume allow-when-locked=true {
        spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+ -l 1.0"
    }
    XF86AudioLowerVolume allow-when-locked=true {
        spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"
    }
    XF86AudioMute allow-when-locked=true {
        spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
    }
    XF86AudioMicMute allow-when-locked=true {
        spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
    }
    XF86AudioPlay allow-when-locked=true {
        spawn-sh "playerctl play-pause"
    }
    XF86AudioStop allow-when-locked=true {
        spawn-sh "playerctl stop"
    }
    XF86AudioPrev allow-when-locked=true {
        spawn-sh "playerctl previous"
    }
    XF86AudioNext allow-when-locked=true {
        spawn-sh "playerctl next"
    }
    XF86MonBrightnessUp allow-when-locked=true {
        spawn "brightnessctl" "--class=backlight" "set" "+10%"
    }
    XF86MonBrightnessDown allow-when-locked=true {
        spawn "brightnessctl" "--class=backlight" "set" "10%-"
    }
    Mod+O repeat=false {
        toggle-overview
    }
    Mod+Shift+C repeat=false {
        close-window
    }
    Mod+Left {
        focus-column-left
    }
    Mod+Down {
        focus-window-down
    }
    Mod+Up {
        focus-window-up
    }
    Mod+Right {
        focus-column-right
    }
    Mod+H {
        focus-column-left
    }
    Mod+J {
        focus-window-down
    }
    Mod+K {
        focus-window-up
    }
    Mod+L {
        focus-column-right
    }
    Mod+Ctrl+Left {
        move-column-left
    }
    Mod+Ctrl+Down {
        move-window-down
    }
    Mod+Ctrl+Up {
        move-window-up
    }
    Mod+Ctrl+Right {
        move-column-right
    }
    Mod+Ctrl+H {
        move-column-left
    }
    Mod+Ctrl+J {
        move-window-down
    }
    Mod+Ctrl+K {
        move-window-up
    }
    Mod+Ctrl+L {
        move-column-right
    }
    // Mod+Shift+Down  { focus-monitor-down; }
    // Mod+Shift+Up    { focus-monitor-up; }
    // Mod+Shift+Right { focus-monitor-right; }
    Mod+Shift+H {
        focus-monitor-left
    }
    // Mod+Shift+J     { focus-monitor-down; }
    // Mod+Shift+K     { focus-monitor-up; }
    Mod+Shift+L {
        focus-monitor-right
    }
    Mod+Shift+Ctrl+Left {
        move-column-to-monitor-left
    }
    // Mod+Shift+Ctrl+Down  { move-column-to-monitor-down; }
    // Mod+Shift+Ctrl+Up    { move-column-to-monitor-up; }
    Mod+Shift+Ctrl+Right {
        move-column-to-monitor-right
    }
    Mod+Shift+Ctrl+H {
        move-column-to-monitor-left
    }
    // Mod+Shift+Ctrl+J     { move-column-to-monitor-down; }
    // Mod+Shift+Ctrl+K     { move-column-to-monitor-up; }
    Mod+Shift+Ctrl+L {
        move-column-to-monitor-right
    }
    Mod+U {
        focus-workspace-down
    }
    Mod+I {
        focus-workspace-up
    }
    Mod+Alt+J {
        move-column-to-workspace-down
    }
    Mod+Alt+K {
        move-column-to-workspace-up
    }
    Mod+Alt+U {
        move-column-to-workspace-down
    }
    Mod+Alt+I {
        move-column-to-workspace-up
    }
    Mod+Shift+U {
        move-workspace-down
    }
    Mod+Shift+I {
        move-workspace-up
    }
    Mod+WheelScrollDown cooldown-ms=150 {
        focus-workspace-down
    }
    Mod+WheelScrollUp cooldown-ms=150 {
        focus-workspace-up
    }
    Mod+Ctrl+WheelScrollDown cooldown-ms=150 {
        move-column-to-workspace-down
    }
    Mod+Ctrl+WheelScrollUp cooldown-ms=150 {
        move-column-to-workspace-up
    }
    Mod+WheelScrollRight {
        focus-column-right
    }
    Mod+WheelScrollLeft {
        focus-column-left
    }
    Mod+Ctrl+WheelScrollRight {
        move-column-right
    }
    Mod+Ctrl+WheelScrollLeft {
        move-column-left
    }
    Mod+Shift+WheelScrollDown {
        focus-column-right
    }
    Mod+Shift+WheelScrollUp {
        focus-column-left
    }
    Mod+Ctrl+Shift+WheelScrollDown {
        move-column-right
    }
    Mod+Ctrl+Shift+WheelScrollUp {
        move-column-left
    }
    Mod+1 {
        focus-workspace 1
    }
    Mod+2 {
        focus-workspace 2
    }
    Mod+3 {
        focus-workspace 3
    }
    Mod+4 {
        focus-workspace 4
    }
    Mod+5 {
        focus-workspace 5
    }
    Mod+6 {
        focus-workspace 6
    }
    Mod+7 {
        focus-workspace 7
    }
    Mod+8 {
        focus-workspace 8
    }
    Mod+9 {
        focus-workspace 9
    }
    // Mod+Ctrl+1 { move-column-to-workspace 1; }
    // Mod+Ctrl+2 { move-column-to-workspace 2; }
    // Mod+Ctrl+3 { move-column-to-workspace 3; }
    // Mod+Ctrl+4 { move-column-to-workspace 4; }
    // Mod+Ctrl+5 { move-column-to-workspace 5; }
    // Mod+Ctrl+6 { move-column-to-workspace 6; }
    // Mod+Ctrl+7 { move-column-to-workspace 7; }
    // Mod+Ctrl+8 { move-column-to-workspace 8; }
    // Mod+Ctrl+9 { move-column-to-workspace 9; }
    Mod+BracketLeft {
        consume-or-expel-window-left
    }
    Mod+BracketRight {
        consume-or-expel-window-right
    }
    Mod+Comma {
        consume-window-into-column
    }
    Mod+Period {
        expel-window-from-column
    }
    Mod+R {
        switch-preset-column-width
    }
    // Cycling through the presets in reverse order is also possible.
    // Mod+R { switch-preset-column-width-back; }
    // Mod+Shift+R {
    //     switch-preset-window-height
    // }
    // Mod+Ctrl+R {
    //     reset-window-height
    // }
    Mod+F {
        maximize-column
    }
    Mod+Shift+F {
        fullscreen-window
    }
    Mod+Ctrl+F {
        expand-column-to-available-width
    }
    // Mod+C { center-column; }
    Mod+Ctrl+C {
        center-visible-columns
    }
    Mod+Minus {
        set-column-width "-10%"
    }
    Mod+Equal {
        set-column-width "+10%"
    }
    // Finer height adjustments when in column with other windows.
    Mod+Shift+Minus {
        set-window-height "-10%"
    }
    Mod+Shift+Equal {
        set-window-height "+10%"
    }
    // Move the focused window between the floating and the tiling layout.
    Mod+V {
        toggle-window-floating
    }
    Mod+Shift+V {
        switch-focus-between-floating-and-tiling
    }
    Mod+W {
        toggle-column-tabbed-display
    }
    // screenshot
    Mod+Alt+4 {
        spawn "sh" "-c" "grim -g \"$(slurp)\" ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png && notify-send 'Screenshot' 'Area screenshot saved'"
    }
    // Fullscreen and save
    Mod+Alt+5 {
        spawn "sh" "-c" "grim ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png && notify-send -t 2000 'Screenshot' 'Fullscreen screenshot saved'"
    }
    // Select area to clipboard
    Mod+Shift+4 {
        spawn "sh" "-c" "grim -g \"$(slurp)\" - | wl-copy && notify-send -t 2000 'Screenshot' 'Area copied to clipboard'"
    }
    // area screenshot → annotate in swappy
    Mod+Shift+5 {
    spawn "sh" "-c" "grim -g \"$(slurp)\" - | swappy -f -"
    }
    Mod+Escape allow-inhibiting=false {
        toggle-keyboard-shortcuts-inhibit
    }
    Mod+Shift+E {
        quit
    }
    Ctrl+Alt+Delete {
        quit
    }
    Mod+Shift+P {
        power-off-monitors
    }
}
 // include "theme.kdl"

