# Startup

exec-once= bash -c "wl-paste --watch cliphist store &"
exec-once= fcitx5 -d
exec-once= emacs --daemon
exec-once= dms run # DankShell

# Workspace Variables
$ws_game    = 1
$ws_shell   = 2
$ws_web     = 3
$ws_music   = 4
$ws_image   = 5
$ws_chat    = 6
$ws_audio   = 7
$ws_video   = 8
$ws_program = 9
$ws_extra   = 0

# Monitors

source = ./hypr-monitors.conf
source = ./dms/outputs.conf

# Environment

# env=HYPRCURSOR_THEME,Bibata-Modern-Ice
env=HYPRCURSOR_SIZE,24
env=XDG_CURRENT_DESKTOP,Hyprland
env=XDG_SESSION_TYPE,wayland
env=XDG_SESSION_DESKTOP,Hyprland
env=QT_QPA_PLATFORM,wayland
env=QT_QPA_PLATFORMTHEME,qt6ct
env=XCURSOR_THEME,Bibata-Modern-Ice
env=XCURSOR_SIZE,24

# Colors
source = ./hypr-colors.conf

# Settings

animations {
  bezier=myBezier, 0.05, 0.9, 0.1, 1.05
  animation=windows, 1, 6, myBezier
  animation=windowsOut, 1, 6, default, popin 80%
  animation=border, 1, 8, default
  animation=borderangle, 1, 6, default
  animation=fade, 1, 6, default
  animation=workspaces, 1, 3, default
  enabled=true
}

debug {
  disable_logs=true
}

decoration {
  blur {
    enabled=true
    new_optimizations=on
    passes=2
    size=3
    xray=true
  }

  shadow {
    color=$shadow
    enabled=true
    range=4
    render_power=4
  }
  rounding=10
}

dwindle {
  preserve_split=true
  pseudotile=true
}

ecosystem {
  no_donation_nag=true
  no_update_news=true
}

general {
  border_size=2
  col.active_border=$primary_container
  col.inactive_border=$secondary_container
  gaps_in=2
  gaps_out=4
  resize_on_border = true
  layout=dwindle
}

input {
  touchpad {
    disable_while_typing=true
    drag_lock=false
    middle_button_emulation=true
    natural_scroll=true
    scroll_factor=0.500000
    tap-to-click=true
  }

  follow_mouse=1
  kb_layout=us
  kb_model=
  kb_options=
  kb_rules=
  kb_variant=
  numlock_by_default=true
  sensitivity=0.0
}

render {
  cm_enabled = true
  cm_auto_hdr = 0
}

misc {
  disable_hyprland_logo=true
  disable_splash_rendering=true
  key_press_enables_dpms=true
  mouse_move_enables_dpms=true
}

quirks {
  prefer_hdr = 0
}

plugin {
  # hyprexpo {
  #   columns = 3
  #   gap_size = 5
  #   bg_col = $background
  #   workspace_method = center current
  #   gesture_distance = 300
  # }
}

# Window Rules

# Rule :: Window
$idleInhibFs = idle_inhibit fullscreen
$idleInhibFo = idle_inhibit focus
$ws          = workspace


  windowrule = match:class ^(floorp)$,                               $idleInhibFs
  windowrule = match:class ^(firefox)$,                              $idleInhibFs
  windowrule = match:class ^(ghostty)$,                              $idleInhibFs
  windowrule = match:class ^(brave-browser)$,                        $idleInhibFs

  windowrule = match:class ^(mpv)$,                                  $idleInhibFo
  windowrule = match:class ^(firefox)$,                              $idleInhibFo
  windowrule = match:class ^(floorp)$,                               $idleInhibFo
  windowrule = match:class ^(spotify)$,                              $idleInhibFo
  windowrule = match:class ^(Emacs|emacs)$,                          $idleInhibFo
  windowrule = match:class ^(brave-browser)$,                        $idleInhibFo
  windowrule = match:class ^(Discord|discord)$,                      $idleInhibFo

  windowrule = match:class ^(Discord|discord)$,                      opacity 0.98 0.90
  windowrule = match:class ^(Emacs|emacs)$,                          opacity 0.96 0.90

  windowrule = match:class ^(.*Emulator.*)$,                         float on
  windowrule = match:class ^(.*desktop-portal.*)$,                   float on
  windowrule = match:class ^(org.quickshell)$,                       float on
  windowrule = match:class ^(polkit.*agent.*)$,                      float on
  windowrule = match:class ^(praat)$,                                float on
  windowrule = match:class ^(network)$,                              float on
  windowrule = match:class ^(nm-)$,                                  float on
  windowrule = match:class ^(Network)$,                              float on
  windowrule = match:class ^(Rofi)$,                                 float on
  windowrule = match:class ^(Gimp)$,                                 float on
  windowrule = match:class ^(thunar)$,                               float on
  windowrule = match:class ^(Nautilus)$,                             float on
  windowrule = match:title ^(LmDev-.*)$,                             float on
  windowrule = match:class ^(notification)$,                         float on
  windowrule = match:class ^(Genymotion Player)$,                    float on
  windowrule = match:class ^(launcher)$,                             float on
  windowrule = match:class steam, match:title ^(Friends List)$,      float on

  windowrule = match:class ^(Spotify)$,                              tile on
  windowrule = match:title ^(Minecraft)$,                            tile on

  windowrule = match:class ^(KeePassXC)$,                            $ws $ws_shell
  windowrule = match:class ^(firefox)$,                              $ws $ws_web
  windowrule = match:class ^(floorp)$,                               $ws $ws_web
  windowrule = match:class ^(brave-browser)$,                        $ws $ws_web
  windowrule = match:class ^(Spotify)$,                              $ws $ws_music
  windowrule = match:class ^(discord)$,                              $ws $ws_chat
  windowrule = match:class ^(signal)$, match:title ^(Signal)$,       $ws $ws_chat
  windowrule = match:class ^(.*)$, match:title ^(.*WhatsApp.*)$,     $ws $ws_chat
  windowrule = match:class ^(.*obs.*)$,                              $ws $ws_video
  windowrule = match:title ^(Minecraft)$,                            $ws $ws_game


# Rule :: Workspace

  workspace = 1, layout:scrolling

# Commands
# :Alias:         :Command:

$lock            = dms ipc call lock lock
$screenshot      = grimblast --cursor copy output
$screenshotarea  = hyprctl keyword animation 'fadeOut,0,0,default'; grimblast copy area; hyprctl keyword animation 'fadeOut,1,4,default'
$set_ws_layout   = $HOME/nixos/configs/hypr/set-ws-layout.sh

#$colorpick       = hyprpicker -a -f hex
$colorpick       = dms ipc call color-picker toggleInstant
$emacs           = emacsclient -c -a 'emacs'
$discord         = discord --enable-blink-features=MiddleClickAutoscroll

# Binds

# Binds :: Modifiers
$none          =

$altMod        =  ALT
$mainMod       =  SUPER

$noneCtrl      =  $none CTRL
$altCtrl       =  $altMod CTRL
$mainCtrl      =  $mainMod CTRL

$noneShift     =  $none SHIFT
$altShift      =  $altMod SHIFT
$mainShift     =  $mainMod SHIFT

$altCtrlShift  =  $altCtrl SHIFT
$noneCtrlShift =  $noneCtrl SHIFT
$mainCtrlShift =  $mainCtrl SHIFT

# Binds :: Programs

#:Bind:   :Modifier:       :Key:                  :Command:                       :Args:
  bind   = $altMod,         Return,                exec,                           ghostty
  bind   = $altShift,       Return,                exec,                           foot
  bind   = $mainShift,      D,                     exec,                           $discord
  bind   = $mainShift,      S,                     exec,                           signal-desktop
  bind   = $mainShift,      E,                     exec,                           $emacs
  bind   = $mainShift,      F,                     exec,                           focus
  bind   = $mainMod,        E,                     exec,                           thunar
  bind   = $mainMod,        S,                     exec,                           spotify
  bind   = $mainMod,        P,                     exec,                           $colorpick

  bind   = $none,           Print,                 exec,                           $screenshotarea
  bind   = $noneShift,      Print,                 exec,                           $screenshot
  bind   = $mainMod,        Space,                 exec,                           dms ipc call spotlight toggle
  bind   = $mainMod,        X,                     exec,                           dms ipc call powermenu toggle
  bind   = $mainMod,        M,                     exec,                           dms ipc call processlist toggle
  bind   = $mainMod,        I,                     exec,                           dms ipc call settings toggle
  bind   = $mainMod,        V,                     exec,                           dms ipc call clipboard toggle
  bind   = $mainCtrl,       P,                     exec,                           dms ipc call notepad toggle
  bind   = $mainCtrl,       C,                     exec,                           dms ipc call control-center toggle
  bind   = $mainMod,        N,                     exec,                           dms ipc call notifications toggle
  bind   = $mainShift,      N,                     exec,                           dms ipc call night toggle
  bind   = $mainCtrl,       B,                     exec,                           dms ipc call bar toggle

  # bind   = $mainMod,        G,                     hyprexpo:expo, toggle
  bind   = $mainShift,      P,                     pseudo,
  bind   = $mainMod,        C,                     killactive,
  bind   = $altMod,         F4,                    killactive,
  bind   = $mainMod,        F,                     togglefloating,
  bind   = $mainCtrl,       F,                     fullscreen
  # bind   = $mainCtrl,       S,                     togglesplit,
  binde  = $mainMod,        right,                 resizeactive,                   10 0
  binde  = $mainMod,        left,                  resizeactive,                   -10 0
  binde  = $mainMod,        up,                    resizeactive,                   0 -10
  binde  = $mainMod,        down,                  resizeactive,                   0 10
  bind   = $mainCtrl,       S,                     exec,                           $HOME/nixos/configs/hypr/ws-layout-toggle.sh
  bind   = $mainCtrl,       Q,                     exec,                           $lock
  bind   = $mainMod,        F4,                    exit,

# Binds :: Navigation

#:Bind:   :Modifier:       :Key:                  :Command:                       :Args:
  bind   = $mainMod,        H,                     movefocus,                      l
  bind   = $mainMod,        L,                     movefocus,                      r
  bind   = $mainMod,        K,                     movefocus,                      u
  bind   = $mainMod,        J,                     movefocus,                      d
  # bind   = $mainMod,        K,                     layoutmsg,                      move -col     # Binds for 'scrolling' layout
  # bind   = $mainMod,        J,                     layoutmsg,                      move +col     # Binds for 'scrolling' layout
  bind   = $mainMod,        comma,                 focusmonitor,                   -1
  bind   = $mainMod,        period,                focusmonitor,                   +1
  bind   = $mainShift,      H,                     movewindow,                     l
  bind   = $mainShift,      L,                     movewindow,                     r
  bind   = $mainShift,      K,                     movewindow,                     u
  bind   = $mainShift,      J,                     movewindow,                     d
  bind   = $mainShift,      comma,                 movecurrentworkspacetomonitor,  -1
  bind   = $mainShift,      period,                movecurrentworkspacetomonitor,  +1

  bind   = $mainMod,        $ws_game,              workspace,                      $ws_game
  bind   = $mainMod,        $ws_shell,             workspace,                      $ws_shell
  bind   = $mainMod,        $ws_web,               workspace,                      $ws_web
  bind   = $mainMod,        $ws_music,             workspace,                      $ws_music
  bind   = $mainMod,        $ws_image,             workspace,                      $ws_image
  bind   = $mainMod,        $ws_chat,              workspace,                      $ws_chat
  bind   = $mainMod,        $ws_audio,             workspace,                      $ws_audio
  bind   = $mainMod,        $ws_video,             workspace,                      $ws_video
  bind   = $mainMod,        $ws_program,           workspace,                      $ws_program
  bind   = $mainMod,        $ws_extra,             workspace,                      name:extra

  bind   = $mainShift,      $ws_game,              movetoworkspace,                $ws_game
  bind   = $mainShift,      $ws_shell,             movetoworkspace,                $ws_shell
  bind   = $mainShift,      $ws_web,               movetoworkspace,                $ws_web
  bind   = $mainShift,      $ws_music,             movetoworkspace,                $ws_music
  bind   = $mainShift,      $ws_image,             movetoworkspace,                $ws_image
  bind   = $mainShift,      $ws_chat,              movetoworkspace,                $ws_chat
  bind   = $mainShift,      $ws_audio,             movetoworkspace,                $ws_audio
  bind   = $mainShift,      $ws_video,             movetoworkspace,                $ws_video
  bind   = $mainShift,      $ws_program,           movetoworkspace,                $ws_program
  bind   = $mainShift,      $ws_extra,             movetoworkspace,                name:extra

  bind   = $altShift,       $ws_game,              movetoworkspacesilent,          $ws_game
  bind   = $altShift,       $ws_shell,             movetoworkspacesilent,          $ws_shell
  bind   = $altShift,       $ws_web,               movetoworkspacesilent,          $ws_web
  bind   = $altShift,       $ws_music,             movetoworkspacesilent,          $ws_music
  bind   = $altShift,       $ws_image,             movetoworkspacesilent,          $ws_image
  bind   = $altShift,       $ws_chat,              movetoworkspacesilent,          $ws_chat
  bind   = $altShift,       $ws_audio,             movetoworkspacesilent,          $ws_audio
  bind   = $altShift,       $ws_video,             movetoworkspacesilent,          $ws_video
  bind   = $altShift,       $ws_program,           movetoworkspacesilent,          $ws_program
  bind   = $altShift,       $ws_extra,             movetoworkspacesilent,          name:extra

  bind   = $mainCtrlShift,  right,                 movetoworkspace,                +1
  bind   = $mainCtrlShift,  left,                  movetoworkspace,                -1
  bind   = $altCtrlShift,   right,                 movetoworkspacesilent,          +1
  bind   = $altCtrlShift,   left,                  movetoworkspacesilent,          -1

  bind   = $mainMod,        mouse_down,            workspace,                      e+1
  bind   = $mainMod,        mouse_up,              workspace,                      e-1
  bind   = $mainMod,        Tab,                   workspace,                      e+1
  bind   = $mainShift,      Tab,                   workspace,                      e-1
  bind   = $mainCtrl,       right,                 workspace,                      +1
  bind   = $mainCtrl,       left,                  workspace,                      -1
  bindm  = $mainMod,        mouse:272,             movewindow
  bindm  = $mainMod,        mouse:273,             resizewindow


# Binds :: MultiMedia

  bindl  = $none,           XF86AudioPlay,         exec,                           playerctl play-pause
  bindl  = $none,           XF86AudioNext,         exec,                           playerctl next
  bindl  = $none,           XF86AudioPrev,         exec,                           playerctl previous

  bindl  = $none,           XF86AudioMute,         exec,                           dms ipc call audio mute
  bindl  = $none,           XF86AudioMicMute,      exec,                           dms ipc call audio micmute
  bindle = $none,           XF86AudioRaiseVolume,  exec,                           dms ipc call audio increment 3
  bindle = $none,           XF86AudioLowerVolume,  exec,                           dms ipc call audio decrement 3

  bindle = $none,           XF86MonBrightnessUp,   exec,                           dms ipc call brightness increment 5 ""
  bindle = $none,           XF86MonBrightnessDown, exec,                           dms ipc call brightness decrement 5 ""

# Binds :: Submap

# Binds :: Submap :: Resize
  bind   = $mainMod,        R,                    submap,                          resize

  submap = resize

  bind   = $none,           escape,               submap,                          reset

  binde  = $none,           left,                 resizeactive,                    -10 0
  bindr  = $none,           left,                 submap,                          reset
  binde  = $none,           right,                resizeactive,                    10 0
  bindr  = $none,           right,                submap,                          reset
  binde  = $none,           up,                   resizeactive,                    0 10
  bindr  = $none,           up,                   submap,                          reset
  binde  = $none,           down,                 resizeactive,                    0 -10
  bindr  = $none,           down,                 submap,                          reset

  binde  = $none,           H,                    resizeactive,                   -10 0
  bindr  = $none,           H,                    submap,                         reset
  binde  = $none,           J,                    resizeactive,                   0 -10
  bindr  = $none,           J,                    submap,                         reset
  binde  = $none,           K,                    resizeactive,                   0 10
  bindr  = $none,           K,                    submap,                         reset
  binde  = $none,           L,                    resizeactive,                   10 0
  bindr  = $none,           L,                    submap,                         reset

  submap=reset

# Binds :: Submap :: Browser
  bind   = $mainMod,        B,                    submap,                         browser

  submap = browser

  bind   = $none,           B,                    exec,                           brave
  bindr  = $none,           B,                    submap,                         reset

  bind   = $noneShift,      F,                    exec,                           firefox
  bindr  = $noneShift,      F,                    submap,                         reset

  bind   = $none,           F,                    exec,                           floorp
  bindr  = $none,           F,                    submap,                         reset

  bind   = $none,           escape,               submap,                         reset
  submap = reset

# Binds :: Submap :: Video
  bind   = $mainShift,      V,                    submap,                         video
  submap = video

  bind   = $none,           O,                    exec,                           obs
  bindr  = $none,           O,                    submap,                         reset

  bind   = $none,           V,                    exec,                           kdenlive
  bindr  = $none,           V,                    submap,                         reset

  bind   = $none,           escape,               submap,                         reset
  submap = reset

# Binds :: Global :: Discord
  bind = $none,             F7,                   pass,                           class:^(discord|Discord)$
  bind = $none,             F8,                   pass,                           class:^(discord|Discord)$
  # bind = $none,             T,                    pass,                           class:^(discord|Discord)$

# Binds :: Global :: OBS
  bind = $none,             F9,                   pass,                           class:^(.*obs.*)$

# Gestures

gesture = 3, horizontal,  workspace

source = ./dms/outputs.conf

source = ./dms/cursor.conf
