hyprland: hyperconf to lua

This commit is contained in:
Black_Raven committed 2026-09-09 00:22:18 +03:00
1 parent b5920c6211
commit fe0d9e5198
17 files changed
+334 -345

No files matched your search

+19 -1
View File
@@ -1,3 +1,4 @@
{ pkgs, ... }:
{
imports = [
./host/bluetooth.nix
@@ -13,7 +14,24 @@
#./host/ai-agent.nix
];
programs.hyprland.enable = true;
programs = {
dconf.enable = true;
hyprland.enable = true;
};
xdg.portal = {
enable = true;
xdgOpenUsePortal = true;
extraPortals = with pkgs; [
xdg-desktop-portal-hyprland
xdg-desktop-portal-gtk
xdg-desktop-portal-termfilechooser
];
config = {
common.default = [ "hyprland" "gtk" ];
hyprland.default = [ "hyprland" "gtk" ];
};
};
services = {
udisks2.enable = true;
fstrim.enable = true;
+4 -3
View File
@@ -1,8 +1,9 @@
{
{ lib, ... }: {
environment.variables = {
EDITOR = "hx";
RANGER_LOAD_DEFAULT_RC = "FALSE";
QT_QPA_PLATFORMTHEME = "qt5ct";
GSETTINGS_BACKEND = "keyfile";
GTK_USE_PORTAL = "1";
QT_QPA_PLATFORMTHEME = lib.mkForce "xdgdesktopportal";
TDESKTOP_USE_GTK_FILE_DIALOG = "1";
};
}
+1
View File
@@ -4,6 +4,7 @@
./user/yazi.nix
./user/sleepMode.nix
./user/ghostty.nix
./user/qt.nix
./user/zed-idea.nix
./user/walker.nix
./user/btop.nix
+5 -2
View File
@@ -1,4 +1,7 @@
{ config, inputs, pkgs, ... }: {
{ config, inputs, pkgs, lib, ... }:
let
hyprLua = import ./hyprland/lua.nix { inherit lib; };
in {
imports = [ inputs.ags.homeManagerModules.default ];
programs.ags = {
@@ -20,7 +23,7 @@
pulsemixer
];
wayland.windowManager.hyprland.settings.exec-once = [ "ags run" ];
wayland.windowManager.hyprland.settings.on = [ (hyprLua.onStart [ "ags run" ]) ];
xdg.configFile."ags".source = (pkgs.callPackage ./ags/ags.nix { colors = config.lib.stylix.colors; });
}
+109 -200
View File
@@ -1,218 +1,127 @@
{ pkgs, lib, config, swww_flags, inputs }: {
home.packages = with pkgs; [
ghostty
pamixer
wofi
clipse
wl-clipboard
wl-clip-persist
xclip
];
wayland.windowManager.hyprland =
let
colors = config.lib.stylix.colors;
wallpaper_changer = pkgs.writers.writePython3Bin "wallpaper_changer" {
libraries = [ pkgs.python3Packages.requests ];
flakeIgnore = [ "E501" "E111" "E701" "E241" "E731" ];
} /*py*/ ''
from random import choice
from os import system, listdir
{ pkgs, lib, config, swww_flags, inputs, host ? null }:
let
hyprLua = import ./hyprland/lua.nix { inherit lib; };
direction = { left = "l"; right = "r"; up = "u"; down = "d"; };
wallpaper_changer = pkgs.writers.writePython3Bin "wallpaper_changer" {
libraries = [ pkgs.python3Packages.requests ];
flakeIgnore = [ "E501" "E111" "E701" "E241" "E731" ];
} /*py*/ ''
from random import choice
from os import system, listdir
folder = "${config.home.homeDirectory}/wallpapers"
filename = choice(listdir(folder))
system(f"${lib.getExe pkgs.awww} img {folder}/{filename} ${swww_flags}")
'';
workspaceBinds = lib.concatMap (workspace:
let key = if workspace == 10 then "0" else toString workspace; workspaceValue = toString workspace;
in [
(hyprLua.bind "SUPER + ${key}" "hl.dsp.focus({ workspace = ${workspaceValue} })")
(hyprLua.bind "SUPER + SHIFT + ${key}" "hl.dsp.window.move({ workspace = ${workspaceValue}, follow = false })")
]) (lib.range 1 10);
in {
imports = lib.optional (host != null && builtins.pathExists ../../host/${host.name}/modules/hyprland.nix) ../../host/${host.name}/modules/hyprland.nix;
folder = "${config.home.homeDirectory}/wallpapers"
filename = choice(listdir(folder))
system(f"${lib.getExe pkgs.awww} img {folder}/{filename} ${swww_flags}")
'';
in {
home.packages = with pkgs; [ ghostty pamixer wofi clipse wl-clipboard wl-clip-persist xclip ];
wayland.windowManager.hyprland = {
enable = true;
configType = "hyprlang";
configType = "lua";
xwayland.enable = true;
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
plugins = with inputs.hyprland-plugins.packages.${pkgs.stdenv.hostPlatform.system}; [
# hyprbars # Version mismatch
];
plugins = with inputs.hyprland-plugins.packages.${pkgs.stdenv.hostPlatform.system}; [ ];
settings = {
"$mainMod" = "SUPER";
ecosystem = {
no_donation_nag = true;
no_update_news = true;
};
env = [
"XDG_SESSION_TYPE,wayland"
"QT_QPA_PLATFORM,wayland"
"XDG_CURRENT_DESKTOP,Hyprland"
"XDG_SESSION_DESKTOP,Hyprland"
"XCURSOR_SIZE, ${toString config.stylix.cursor.size}"
"XCURSOR_THEME, ${config.stylix.cursor.name}"
"XDG_SCREENSHOTS_DIR,~/screens"
];
cursor.no_hardware_cursors = true;
debug = {
disable_logs = false;
enable_stdout_logs = true;
};
misc = {
focus_on_activate = true;
};
input = {
kb_layout = "us,ru";
kb_options = "grp:caps_toggle";
numlock_by_default = true;
follow_mouse = 1;
touchpad = {
natural_scroll = false;
config = {
ecosystem = { no_donation_nag = true; no_update_news = true; };
cursor.no_hardware_cursors = 1;
debug = { disable_logs = false; enable_stdout_logs = true; };
general."col.inactive_border" = lib.mkDefault "rgba(00000000)";
decoration = { inactive_opacity = lib.mkDefault 0.95; border_part_of_window = false; };
misc.focus_on_activate = true;
input = {
kb_layout = "us,ru"; kb_options = "grp:caps_toggle"; numlock_by_default = true;
follow_mouse = 1; touchpad.natural_scroll = false; sensitivity = 0;
};
sensitivity = 0;
gestures = { workspace_swipe_invert = true; workspace_swipe_distance = 200; workspace_swipe_forever = true; };
};
gestures = {
workspace_swipe_invert = true;
workspace_swipe_distance = 200;
workspace_swipe_forever = true;
};
gesture = [
"3, horizontal, workspace"
env = [
{ _args = [ "XDG_SESSION_TYPE" "wayland" ]; }
{ _args = [ "QT_QPA_PLATFORM" "wayland" ]; }
{ _args = [ "QT_QPA_PLATFORMTHEME" "xdgdesktopportal" ]; }
{ _args = [ "GTK_USE_PORTAL" "1" ]; }
{ _args = [ "TDESKTOP_USE_GTK_FILE_DIALOG" "1" ]; }
{ _args = [ "NIXOS_OZONE_WL" "1" ]; }
{ _args = [ "ELECTRON_OZONE_PLATFORM_HINT" "auto" ]; }
{ _args = [ "XDG_CURRENT_DESKTOP" "Hyprland" ]; }
{ _args = [ "XDG_SESSION_DESKTOP" "Hyprland" ]; }
{ _args = [ "XCURSOR_SIZE" (toString config.stylix.cursor.size) ]; }
{ _args = [ "XCURSOR_THEME" config.stylix.cursor.name ]; }
{ _args = [ "XDG_SCREENSHOTS_DIR" "~/screens" ]; }
];
windowrule = [
"match:class imv, float 1"
"match:class feh, float 1"
"match:class mpv, float 1"
"match:title Список друзей, float 1"
"match:title nmtui, float 1"
"match:title pulsemixer, float 1"
"match:title clipse, float 1"
"match:title clipse, size 622 652"
"match:focus 1, rounding 0"
"match:float 0, match:workspace w[t1], border_size 0"
gesture = [ { fingers = 3; direction = "horizontal"; action = "workspace"; } ];
workspace_rule = [ { workspace = "w[t1]"; gaps_out = 0; } ];
window_rule = [
{ match.class = "imv"; float = true; }
{ match.class = "feh"; float = true; }
{ match.class = "mpv"; float = true; }
{ match.title = "Список друзей"; float = true; }
{ match.title = "wifitui"; float = true; }
{ match.title = "pulsemixer"; float = true; }
{ match.title = "clipse"; float = true; }
{ match.title = "clipse"; size = [ 622 652 ]; }
{ match.focus = true; rounding = 0; }
{ match = { float = false; workspace = "w[t1]"; }; border_size = 0; }
];
exec-once = [
on = [ (hyprLua.onStart [
"systemctl --user start plasma-polkit-agent"
"${lib.getExe' pkgs.dbus "dbus-update-activation-environment"} --systemd --all"
"systemctl --user import-environment XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE WAYLAND_DISPLAY DISPLAY GTK_USE_PORTAL QT_QPA_PLATFORMTHEME TDESKTOP_USE_GTK_FILE_DIALOG NIXOS_OZONE_WL ELECTRON_OZONE_PLATFORM_HINT"
"${lib.getExe' pkgs.awww "awww-daemon"}"
"${pkgs.bash}/bin/bash -c 'sleep 1 && ${lib.getExe wallpaper_changer}'"
"wl-clip-persist --clipboard both"
"clipse -listen"
"${lib.getExe' pkgs.udiskie "udiskie"}"
];
"${lib.getExe wallpaper_changer}"
]) ];
bind = [
"$mainMod, V, exec, ghostty --title=clipse -e clipse"
"$mainMod, Return, exec, ghostty"
"$mainMod, Q, killactive,"
"$mainMod, M, exit,"
"$mainMod, E, exec, ghostty -e sh -c yazi"
"$mainMod, F, togglefloating,"
"$mainMod, J, layoutmsg, togglesplit, # dwindle"
# Move focus with mainMod + arrow keys
"$mainMod, left, movefocus, l"
"$mainMod, right, movefocus, r"
"$mainMod, up, movefocus, u"
"$mainMod, down, movefocus, d"
# Moving windows
"$mainMod SHIFT, left, swapwindow, l"
"$mainMod SHIFT, right, swapwindow, r"
"$mainMod SHIFT, up, swapwindow, u"
"$mainMod SHIFT, down, swapwindow, d"
# Window resizing X Y
"$mainMod CTRL, left, resizeactive, -60 0"
"$mainMod CTRL, right, resizeactive, 60 0"
"$mainMod CTRL, up, resizeactive, 0 -60"
"$mainMod CTRL, down, resizeactive, 0 60"
# Switch workspaces with mainMod + [0-9]
"$mainMod, 1, workspace, 1"
"$mainMod, 2, workspace, 2"
"$mainMod, 3, workspace, 3"
"$mainMod, 4, workspace, 4"
"$mainMod, 5, workspace, 5"
"$mainMod, 6, workspace, 6"
"$mainMod, 7, workspace, 7"
"$mainMod, 8, workspace, 8"
"$mainMod, 9, workspace, 9"
"$mainMod, 0, workspace, 10"
# Move active window to a workspace with mainMod + SHIFT + [0-9]
"$mainMod SHIFT, 1, movetoworkspacesilent, 1"
"$mainMod SHIFT, 2, movetoworkspacesilent, 2"
"$mainMod SHIFT, 3, movetoworkspacesilent, 3"
"$mainMod SHIFT, 4, movetoworkspacesilent, 4"
"$mainMod SHIFT, 5, movetoworkspacesilent, 5"
"$mainMod SHIFT, 6, movetoworkspacesilent, 6"
"$mainMod SHIFT, 7, movetoworkspacesilent, 7"
"$mainMod SHIFT, 8, movetoworkspacesilent, 8"
"$mainMod SHIFT, 9, movetoworkspacesilent, 9"
"$mainMod SHIFT, 0, movetoworkspacesilent, 10"
"$mainMod SHIFT, F, fullscreen"
# Scroll through existing workspaces with mainMod + scroll
"$mainMod, mouse_down, workspace, e+1"
"$mainMod, mouse_up, workspace, e-1"
# Keyboard backlight
"$mainMod, F3, exec, ${lib.getExe pkgs.brightnessctl} -d *::kbd_backlight set +33%"
"$mainMod, F2, exec, ${lib.getExe pkgs.brightnessctl} -d *::kbd_backlight set 33%-"
# Volume and Media Control
", XF86AudioMute, exec, pamixer -t"
", XF86AudioMicMute, exec, pamixer --default-source -m"
", XF86AudioPlay, exec, ${lib.getExe pkgs.playerctl} play-pause"
", XF86AudioPrev, exec, ${lib.getExe pkgs.playerctl} position 5-"
", XF86AudioNext, exec, ${lib.getExe pkgs.playerctl} position 5+"
", XF86Explorer, exec, ghostty -e sh -c yazi"
", XF86Mail, exec, thunderbird"
", XF86WWW, exec, google-chrome-stable" # TODO: Replace hard-code to some variable
# Brightness control
", XF86MonBrightnessDown, exec, ${lib.getExe pkgs.brightnessctl} set 5%- "
", XF86MonBrightnessUp, exec, ${lib.getExe pkgs.brightnessctl} set +5% "
# Waybar
"$mainMod, B, exec, pkill -SIGUSR1 waybar"
#"$mainMod, W, exec, pkill -SIGUSR2 waybar"
"$mainMod, W, exec, ${lib.getExe wallpaper_changer}"
];
binde = [
", XF86AudioRaiseVolume, exec, pamixer -i 5 "
", XF86AudioLowerVolume, exec, pamixer -d 5 "
];
bindo = [
", XF86AudioPrev, exec, ${lib.getExe pkgs.playerctl} previous"
", XF86AudioNext, exec, ${lib.getExe pkgs.playerctl} next"
];
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = [
"$mainMod, mouse:272, movewindow"
"$mainMod, mouse:273, resizewindow"
(hyprLua.bind "SUPER + V" (hyprLua.exec "ghostty --title=clipse -e clipse"))
(hyprLua.bind "SUPER + RETURN" (hyprLua.exec "ghostty"))
(hyprLua.bind "SUPER + Q" "hl.dsp.window.close()")
(hyprLua.bind "SUPER + M" "hl.dsp.exit()")
(hyprLua.bind "SUPER + E" (hyprLua.exec "ghostty -e sh -c yazi"))
(hyprLua.bind "SUPER + F" "hl.dsp.window.float({ action = \"toggle\" })")
(hyprLua.bind "SUPER + J" "hl.dsp.layout(\"togglesplit\")")
(hyprLua.bind "SUPER + LEFT" "hl.dsp.focus({ direction = \"${direction.left}\" })")
(hyprLua.bind "SUPER + RIGHT" "hl.dsp.focus({ direction = \"${direction.right}\" })")
(hyprLua.bind "SUPER + UP" "hl.dsp.focus({ direction = \"${direction.up}\" })")
(hyprLua.bind "SUPER + DOWN" "hl.dsp.focus({ direction = \"${direction.down}\" })")
(hyprLua.bind "SUPER + SHIFT + LEFT" "hl.dsp.window.swap({ direction = \"${direction.left}\" })")
(hyprLua.bind "SUPER + SHIFT + RIGHT" "hl.dsp.window.swap({ direction = \"${direction.right}\" })")
(hyprLua.bind "SUPER + SHIFT + UP" "hl.dsp.window.swap({ direction = \"${direction.up}\" })")
(hyprLua.bind "SUPER + SHIFT + DOWN" "hl.dsp.window.swap({ direction = \"${direction.down}\" })")
(hyprLua.bind "SUPER + CTRL + LEFT" "hl.dsp.window.resize({ x = -60, y = 0, relative = true })")
(hyprLua.bind "SUPER + CTRL + RIGHT" "hl.dsp.window.resize({ x = 60, y = 0, relative = true })")
(hyprLua.bind "SUPER + CTRL + UP" "hl.dsp.window.resize({ x = 0, y = -60, relative = true })")
(hyprLua.bind "SUPER + CTRL + DOWN" "hl.dsp.window.resize({ x = 0, y = 60, relative = true })")
] ++ workspaceBinds ++ [
(hyprLua.bind "SUPER + SHIFT + F" "hl.dsp.window.fullscreen({ action = \"toggle\", mode = \"fullscreen\" })")
(hyprLua.bind "SUPER + mouse_down" "hl.dsp.focus({ workspace = \"e+1\" })")
(hyprLua.bind "SUPER + mouse_up" "hl.dsp.focus({ workspace = \"e-1\" })")
(hyprLua.bind "SUPER + F3" (hyprLua.exec "${lib.getExe pkgs.brightnessctl} -d *::kbd_backlight set +33%"))
(hyprLua.bind "SUPER + F2" (hyprLua.exec "${lib.getExe pkgs.brightnessctl} -d *::kbd_backlight set 33%-"))
(hyprLua.bind "XF86AudioMute" (hyprLua.exec "pamixer -t"))
(hyprLua.bind "XF86AudioMicMute" (hyprLua.exec "pamixer --default-source -m"))
(hyprLua.bind "XF86AudioPlay" (hyprLua.exec "${lib.getExe pkgs.playerctl} play-pause"))
(hyprLua.bind "XF86AudioPrev" (hyprLua.exec "${lib.getExe pkgs.playerctl} position 5-"))
(hyprLua.bind "XF86AudioNext" (hyprLua.exec "${lib.getExe pkgs.playerctl} position 5+"))
(hyprLua.bind "XF86Explorer" (hyprLua.exec "ghostty -e sh -c yazi"))
(hyprLua.bind "XF86Mail" (hyprLua.exec "thunderbird"))
(hyprLua.bind "XF86WWW" (hyprLua.exec "google-chrome-stable"))
(hyprLua.bind "XF86MonBrightnessDown" (hyprLua.exec "${lib.getExe pkgs.brightnessctl} set 5%-"))
(hyprLua.bind "XF86MonBrightnessUp" (hyprLua.exec "${lib.getExe pkgs.brightnessctl} set +5%"))
(hyprLua.bindWithFlags "XF86AudioRaiseVolume" (hyprLua.exec "pamixer -i 5") { repeating = true; })
(hyprLua.bindWithFlags "XF86AudioLowerVolume" (hyprLua.exec "pamixer -d 5") { repeating = true; })
(hyprLua.bindWithFlags "XF86AudioPrev" (hyprLua.exec "${lib.getExe pkgs.playerctl} previous") { long_press = true; })
(hyprLua.bindWithFlags "XF86AudioNext" (hyprLua.exec "${lib.getExe pkgs.playerctl} next") { long_press = true; })
(hyprLua.bindWithFlags "SUPER + mouse:272" "hl.dsp.window.drag()" { mouse = true; })
(hyprLua.bindWithFlags "SUPER + mouse:273" "hl.dsp.window.resize()" { mouse = true; })
];
};
};
+16
View File
@@ -0,0 +1,16 @@
{ lib }:
let
inline = lib.generators.mkLuaInline;
quote = builtins.toJSON;
in rec {
inherit inline;
exec = command: "hl.dsp.exec_cmd(${quote command})";
bind = keys: dispatcher: { _args = [ keys (inline dispatcher) ]; };
bindWithFlags = keys: dispatcher: flags: { _args = [ keys (inline dispatcher) flags ]; };
onStart = commands: {
_args = [
"hyprland.start"
(inline ("function()\n" + lib.concatMapStringsSep "\n" (command: " hl.exec_cmd(${quote command})") commands + "\nend"))
];
};
}
+14
View File
@@ -0,0 +1,14 @@
{ lib, ... }: {
stylix.targets.qt.standardDialogs = "xdgdesktopportal";
home.sessionVariables = {
QT_QPA_PLATFORMTHEME = lib.mkForce "xdgdesktopportal";
TDESKTOP_USE_GTK_FILE_DIALOG = "1";
};
qt = {
enable = true;
platformTheme.name = "qtct";
style.name = "kvantum";
};
}
+5 -2
View File
@@ -1,5 +1,8 @@
{ pkgs, lib, ... }: {
wayland.windowManager.hyprland.settings.exec-once = [ "hyprlock" ];
{ pkgs, lib, ... }:
let
hyprLua = import ./hyprland/lua.nix { inherit lib; };
in {
wayland.windowManager.hyprland.settings.on = [ (hyprLua.onStart [ "hyprlock" ]) ];
programs.hyprlock = let
image = pkgs.fetchurl {
+6 -2
View File
@@ -1,4 +1,7 @@
{
{ lib, ... }:
let
hyprLua = import ./hyprland/lua.nix { inherit lib; };
in {
services = {
walker = {
enable = true;
@@ -9,6 +12,7 @@
};
wayland.windowManager.hyprland.settings.bind = [
"$mainMod, D, exec, walker"
(hyprLua.bind "SUPER + D" (hyprLua.exec "walker"))
];
}
+8 -12
View File
@@ -1,4 +1,5 @@
{ config, pkgs, lib, ... }: let
hyprLua = import ./hyprland/lua.nix { inherit lib; };
c = config.lib.stylix.colors;
wobSocket = ''"''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/wob.sock"'';
@@ -53,16 +54,11 @@ in {
};
};
wayland.windowManager.hyprland.settings = {
bindel = [
", XF86AudioRaiseVolume, exec, ${lib.getExe volumeStep} up"
", XF86AudioLowerVolume, exec, ${lib.getExe volumeStep} down"
", XF86MonBrightnessUp, exec, ${lib.getExe brightnessStep} up"
", XF86MonBrightnessDown, exec, ${lib.getExe brightnessStep} down"
];
bind = [
", XF86AudioMute, exec, ${lib.getExe volumeStep} mute"
];
};
wayland.windowManager.hyprland.settings.bind = [
(hyprLua.bindWithFlags "XF86AudioRaiseVolume" (hyprLua.exec "${lib.getExe volumeStep} up") { repeating = true; locked = true; })
(hyprLua.bindWithFlags "XF86AudioLowerVolume" (hyprLua.exec "${lib.getExe volumeStep} down") { repeating = true; locked = true; })
(hyprLua.bindWithFlags "XF86MonBrightnessUp" (hyprLua.exec "${lib.getExe brightnessStep} up") { repeating = true; locked = true; })
(hyprLua.bindWithFlags "XF86MonBrightnessDown" (hyprLua.exec "${lib.getExe brightnessStep} down") { repeating = true; locked = true; })
(hyprLua.bind "XF86AudioMute" (hyprLua.exec "${lib.getExe volumeStep} mute"))
];
}
+8 -2
View File
@@ -121,8 +121,14 @@ in {
Exec=${lib.getExe fileManager1}
'';
wayland.windowManager.hyprland.settings.windowrule = [
"match:class dragon-drop, move cursor_x-window_w/2 cursor_y-window_h/2"
wayland.windowManager.hyprland.settings.window_rule = [
{
match.class = "dragon-drop";
move = [
"(cursor_x-(window_w*0.5))"
"(cursor_y-(window_h*0.5))"
];
}
];
programs.yazi = {