cleanup WM setup
This commit is contained in:
parent
e8738e504f
commit
e9898b83cc
9 changed files with 447 additions and 398 deletions
|
|
@ -1,398 +0,0 @@
|
|||
{
|
||||
inputs,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
filename = "fht-compositor.toml";
|
||||
|
||||
session-programs = pkgs.writeShellApplication {
|
||||
name = "session-programs";
|
||||
runtimeInputs = with pkgs; [
|
||||
procps
|
||||
util-linux
|
||||
];
|
||||
text = ''
|
||||
restart() {
|
||||
pattern=$1
|
||||
shift
|
||||
pkill -f "$pattern" || true
|
||||
for _ in $(seq 50); do
|
||||
pgrep -f "$pattern" >/dev/null || break
|
||||
sleep 0.1
|
||||
done
|
||||
setsid "$@" >/dev/null 2>&1 </dev/null &
|
||||
}
|
||||
|
||||
restart '/bin/elephant$' systemd-cat -t elephant ${lib.getExe pkgs.elephant}
|
||||
restart 'walker.* --gapplication-service' walker --gapplication-service
|
||||
restart 'gaypanel-wrapped_' systemd-cat -t gaypanel gaypanel
|
||||
restart 'bin/swaybg ' ${lib.getExe pkgs.swaybg} -i ${../../../background.jpg} -m fill
|
||||
restart 'bin/swayosd-server ' ${lib.getExe' pkgs.swayosd "swayosd-server"} --style ${pkgs.writeText "swayosd.css" ''
|
||||
@import url("file://${pkgs.swayosd}/etc/xdg/swayosd/style.css");
|
||||
|
||||
window#osd {
|
||||
background: shade(@theme_bg_color, 1.15);
|
||||
}
|
||||
''}
|
||||
restart 'bin/swaync ' ${lib.getExe' pkgs.swaynotificationcenter "swaync"} --style ${pkgs.writeText "swaync.css" ''
|
||||
@import url("file://${pkgs.swaynotificationcenter}/etc/xdg/swaync/style.css");
|
||||
|
||||
:root {
|
||||
--noti-bg-focus: transparent;
|
||||
--noti-border-color: transparent;
|
||||
--notification-shadow: none;
|
||||
--border-radius: 16px;
|
||||
--notification-icon-size: 48px;
|
||||
--font-size-summary: 14px;
|
||||
--font-size-body: 14px;
|
||||
}
|
||||
|
||||
.control-center {
|
||||
background: shade(@theme_bg_color, 1.1);
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification,
|
||||
.notification-group.collapsed .notification-row .notification {
|
||||
background: shade(@theme_bg_color, 1.25);
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification .notification-default-action:hover,
|
||||
.control-center .control-center-list .notification .notification-default-action:hover,
|
||||
.notification-group.collapsed:hover .notification-row:not(:only-child) .notification {
|
||||
background: shade(@theme_bg_color, 1.4);
|
||||
}
|
||||
|
||||
.control-center .control-center-list-placeholder {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification .notification-default-action .notification-content {
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification .notification-default-action .notification-content .text-box .time {
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification .notification-default-action .notification-content .text-box .body {
|
||||
opacity: 0.8;
|
||||
}
|
||||
''} --config ${
|
||||
(pkgs.formats.json { }).generate "swaync.json" (
|
||||
let
|
||||
default = lib.importJSON "${pkgs.swaynotificationcenter}/etc/xdg/swaync/config.json";
|
||||
in
|
||||
default
|
||||
// lib.genAttrs (map (side: "control-center-margin-${side}") [
|
||||
"top"
|
||||
"bottom"
|
||||
"right"
|
||||
]) (_: 8)
|
||||
// {
|
||||
notification-window-width = 420;
|
||||
ignore-gtk-theme = false;
|
||||
fit-to-screen = false;
|
||||
control-center-height = -1;
|
||||
widget-config = default.widget-config // {
|
||||
notifications = default.widget-config.notifications or { } // {
|
||||
vexpand = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
}
|
||||
# Only locks before suspending, with hyprlock
|
||||
restart 'bin/hypridle ' ${lib.getExe pkgs.hypridle} --config ${pkgs.writeText "hypridle.conf" ''
|
||||
general {
|
||||
lock_cmd = pidof hyprlock || ${lib.getExe pkgs.hyprlock} --config ${
|
||||
let
|
||||
inherit (config.lib.stylix) colors;
|
||||
in
|
||||
pkgs.writeText "hyprlock.conf" ''
|
||||
|
||||
background {
|
||||
path = screenshot
|
||||
blur_passes = 3
|
||||
}
|
||||
|
||||
label {
|
||||
text = $TIME
|
||||
font_size = 96
|
||||
position = 0, 200
|
||||
}
|
||||
|
||||
label {
|
||||
text = cmd[update:60000] date +"%A, %B %-d"
|
||||
font_size = 20
|
||||
position = 0, 110
|
||||
}
|
||||
|
||||
input-field {
|
||||
size = 300, 50
|
||||
outline_thickness = 0
|
||||
inner_color = rgb(${colors.base01})
|
||||
font_color = rgb(${colors.base05})
|
||||
check_color = rgb(${colors.base0D})
|
||||
fade_on_empty = false
|
||||
}
|
||||
''
|
||||
}
|
||||
before_sleep_cmd = loginctl lock-session
|
||||
}
|
||||
''}
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ inputs.fht-compositor.nixosModules.default ];
|
||||
|
||||
# Tapping the power button suspends (which locks the screen, see hypridle above)
|
||||
services.logind.settings.Login.HandlePowerKey = "suspend";
|
||||
|
||||
# Prefer the GNOME portal (e.g. Nautilus as the file picker), falling back to GTK. This replaces
|
||||
# the portal config fht-compositor ships.
|
||||
xdg.portal.config.fht-compositor = {
|
||||
default = [
|
||||
"gnome"
|
||||
"gtk"
|
||||
];
|
||||
|
||||
# GNOME's sends them to GNOME Shell, GTK's to any notification daemon
|
||||
"org.freedesktop.impl.portal.Notification" = [ "gtk" ];
|
||||
|
||||
# GNOME's needs GNOME Shell, and GTK doesn't have one
|
||||
"org.freedesktop.impl.portal.ScreenCast" = [ "fht-compositor" ];
|
||||
};
|
||||
|
||||
environment = {
|
||||
systemPackages = [ session-programs ];
|
||||
etc = {
|
||||
"xdg/walker/config.toml".source = (pkgs.formats.toml { }).generate "walker.toml" {
|
||||
# Take keyboard focus when opened, so you can type into the search straight away
|
||||
force_keyboard_focus = true;
|
||||
theme = "system";
|
||||
};
|
||||
|
||||
# The default theme, minus its hardcoded @define-color palette, so the GTK theme's colors show through
|
||||
"xdg/walker/themes/system/style.css".source = pkgs.runCommand "walker-system-style.css" { } ''
|
||||
sed '/^@define-color/d' ${pkgs.walker.src}/resources/themes/default/style.css > $out
|
||||
'';
|
||||
|
||||
# Only load the providers Walker uses
|
||||
"xdg/elephant/elephant.toml".source = (pkgs.formats.toml { }).generate "elephant.toml" {
|
||||
terminal_cmd = "ptyxis -x";
|
||||
ignored_providers = [
|
||||
"1password"
|
||||
"aptpackages"
|
||||
"archlinuxpkgs"
|
||||
"bitwarden"
|
||||
"bluetooth"
|
||||
"bookmarks"
|
||||
"clipboard"
|
||||
"dnfpackages"
|
||||
"files"
|
||||
"menus"
|
||||
"niriactions"
|
||||
"nirisessions"
|
||||
"playerctl"
|
||||
"protonpass"
|
||||
"providerlist"
|
||||
"runner"
|
||||
"snippets"
|
||||
"symbols"
|
||||
"todo"
|
||||
"unicode"
|
||||
"windows"
|
||||
"wireplumber"
|
||||
];
|
||||
};
|
||||
|
||||
# Use the same search engines as LibreWolf, with its aliases as prefixes (e.g. "@no nix")
|
||||
"xdg/elephant/websearch.toml".source =
|
||||
let
|
||||
inherit (config.programs.firefox.policies) SearchEngines;
|
||||
in
|
||||
(pkgs.formats.toml { }).generate "websearch.toml" {
|
||||
entries = map (
|
||||
engine:
|
||||
{
|
||||
name = engine.Name;
|
||||
url = lib.replaceStrings [ "{searchTerms}" ] [ "%TERM%" ] engine.URLTemplate;
|
||||
default = engine.Name == SearchEngines.Default;
|
||||
}
|
||||
// lib.optionalAttrs (engine ? Alias) { prefix = "${engine.Alias} "; }
|
||||
) SearchEngines.Add;
|
||||
};
|
||||
|
||||
# FHT config
|
||||
${filename}.source = (pkgs.formats.toml { }).generate "config.toml" {
|
||||
autostart = [ "session-programs" ];
|
||||
|
||||
general = {
|
||||
focus-follows-mouse = true;
|
||||
inner-gaps = 10;
|
||||
};
|
||||
|
||||
decorations = {
|
||||
border = {
|
||||
thickness = 4;
|
||||
radius = 12;
|
||||
};
|
||||
blur.disable = true;
|
||||
};
|
||||
|
||||
keybinds = {
|
||||
Alt-Tab = "focus-next-window";
|
||||
Super-q = "close-focused-window";
|
||||
Super-f = "fullscreen-focused-window";
|
||||
Super-Ctrl-q = "quit";
|
||||
Super-Ctrl-r = {
|
||||
action = "run-command";
|
||||
arg = "fht-compositor ipc action reload-config; session-programs";
|
||||
};
|
||||
|
||||
# Runs when Super is tapped on its own (patched in, see lone-modifier.patch)
|
||||
Super_L = {
|
||||
action = "run-command";
|
||||
arg = "walker";
|
||||
};
|
||||
|
||||
Print = {
|
||||
action = "run-command";
|
||||
arg = "${lib.getExe pkgs.grim} -g \"$(${lib.getExe pkgs.slurp})\" - | gradia";
|
||||
};
|
||||
|
||||
Super-t = {
|
||||
action = "run-command";
|
||||
arg = "ptyxis --new-window";
|
||||
};
|
||||
Super-e = {
|
||||
action = "run-command";
|
||||
arg = "nautilus";
|
||||
};
|
||||
Super-c = {
|
||||
action = "run-command";
|
||||
arg = "codium";
|
||||
};
|
||||
Super-b = {
|
||||
action = "run-command";
|
||||
arg = "librewolf";
|
||||
};
|
||||
|
||||
Super-Down = {
|
||||
action = "change-window-proportion";
|
||||
arg = 0.5;
|
||||
};
|
||||
Super-Up = {
|
||||
action = "change-window-proportion";
|
||||
arg = -0.5;
|
||||
};
|
||||
Super-Left = {
|
||||
action = "change-mwfact";
|
||||
arg = -0.1;
|
||||
};
|
||||
Super-Right = {
|
||||
action = "change-mwfact";
|
||||
arg = 0.1;
|
||||
};
|
||||
}
|
||||
// builtins.listToAttrs (
|
||||
builtins.genList (i: {
|
||||
name = "Super-${toString (i + 1)}";
|
||||
value = {
|
||||
action = "focus-workspace";
|
||||
arg = i;
|
||||
};
|
||||
}) 9
|
||||
)
|
||||
# Media keys, with a SwayOSD popup
|
||||
//
|
||||
lib.mapAttrs
|
||||
(_: args: {
|
||||
action = "run-command";
|
||||
arg = "${lib.getExe' pkgs.swayosd "swayosd-client"} ${args}";
|
||||
# Holding raise/lower keeps changing the volume, but holding mute shouldn't keep toggling
|
||||
repeat = !lib.hasSuffix "mute-toggle" args;
|
||||
})
|
||||
{
|
||||
XF86AudioRaiseVolume = "--output-volume raise";
|
||||
XF86AudioLowerVolume = "--output-volume lower";
|
||||
XF86AudioMute = "--output-volume mute-toggle";
|
||||
XF86AudioMicMute = "--input-volume mute-toggle";
|
||||
};
|
||||
|
||||
mousebinds = {
|
||||
Super-Left = "swap-tile";
|
||||
# Works on tiled windows too (patched in, see resize-tiled-windows.patch)
|
||||
Super-Right = "resize-tile";
|
||||
Super-wheeldown = "focus-previous-workspace";
|
||||
Super-wheelup = "focus-next-workspace";
|
||||
};
|
||||
|
||||
input.touchpad = {
|
||||
natural-scrolling = true;
|
||||
click-method = "clickfinger";
|
||||
};
|
||||
|
||||
gesturebinds = {
|
||||
focus-next-workspace = {
|
||||
fingers = 3;
|
||||
direction = "left";
|
||||
min-swipe-distance = 1;
|
||||
};
|
||||
|
||||
focus-previous-workspace = {
|
||||
fingers = 3;
|
||||
direction = "right";
|
||||
min-swipe-distance = 1;
|
||||
};
|
||||
};
|
||||
|
||||
rules = [
|
||||
{
|
||||
match-app-id = [ ".*" ];
|
||||
floating = false;
|
||||
}
|
||||
];
|
||||
|
||||
outputs = {
|
||||
HDMI-A-1.position.x = 0;
|
||||
DP-3.position.x = 1920;
|
||||
};
|
||||
|
||||
cursor = {
|
||||
name = "GoogleDot-Blue";
|
||||
size = 24;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
programs = {
|
||||
hyprlock.enable = true;
|
||||
|
||||
fht-compositor = {
|
||||
enable = true;
|
||||
package =
|
||||
inputs.fht-compositor.packages.${pkgs.stdenv.hostPlatform.system}.default.overrideAttrs
|
||||
(old: {
|
||||
patches = (old.patches or [ ]) ++ [
|
||||
./resize-tiled-windows.patch
|
||||
./lone-modifier.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.makeWrapper ];
|
||||
|
||||
postInstall = (old.postInstall or "") + ''
|
||||
wrapProgram $out/bin/fht-compositor \
|
||||
--add-flags "-c /etc/${filename}"
|
||||
'';
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
215
modules/desktop/wm/fht-compositor/default.nix
Normal file
215
modules/desktop/wm/fht-compositor/default.nix
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
{
|
||||
inputs,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.programs.fht-compositor;
|
||||
filename = "fht-compositor.toml";
|
||||
format = pkgs.formats.toml { };
|
||||
|
||||
# (Re)starts the programs that run alongside the compositor. Run at login, and on Super+Ctrl+R
|
||||
# so they pick up rebuilt versions and config. Each runs as a systemd user unit named
|
||||
# session-<name>, which is stopped (waiting for it to exit, since single-instance apps would
|
||||
# otherwise hand off to the old one) and started again. Logs: journalctl --user -u session-<name>
|
||||
session-programs = pkgs.writeShellApplication {
|
||||
name = "session-programs";
|
||||
runtimeInputs = [ pkgs.dbus ];
|
||||
text = ''
|
||||
# Give the units this session's environment (display, desktop name, etc.)
|
||||
dbus-update-activation-environment --systemd --all
|
||||
|
||||
${lib.concatLines (
|
||||
lib.mapAttrsToList (name: command: ''
|
||||
systemctl --user stop session-${name} 2>/dev/null || true
|
||||
systemd-run --user --unit=session-${name} --collect --quiet -- sh -c ${
|
||||
lib.escapeShellArg "exec ${command}"
|
||||
}
|
||||
'') cfg.sessionPrograms
|
||||
)}
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ inputs.fht-compositor.nixosModules.default ];
|
||||
|
||||
options.programs.fht-compositor = {
|
||||
settings = lib.mkOption {
|
||||
inherit (format) type;
|
||||
default = { };
|
||||
description = "fht-compositor's config, written to /etc/${filename}.";
|
||||
};
|
||||
|
||||
sessionPrograms = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.str;
|
||||
default = { };
|
||||
description = "Commands started at login and restarted on Super+Ctrl+R, as systemd user units named session-<name>.";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
# Prefer the GNOME portal (e.g. Nautilus as the file picker), falling back to GTK. This replaces
|
||||
# the portal config fht-compositor ships.
|
||||
xdg.portal.config.fht-compositor = {
|
||||
default = [
|
||||
"gnome"
|
||||
"gtk"
|
||||
];
|
||||
|
||||
# GNOME's sends them to GNOME Shell, GTK's to any notification daemon
|
||||
"org.freedesktop.impl.portal.Notification" = [ "gtk" ];
|
||||
|
||||
# GNOME's needs GNOME Shell, and GTK doesn't have one
|
||||
"org.freedesktop.impl.portal.ScreenCast" = [ "fht-compositor" ];
|
||||
};
|
||||
|
||||
environment = {
|
||||
# Called by name (rather than by store path), so Super+Ctrl+R after a rebuild runs the new version
|
||||
systemPackages = [ session-programs ];
|
||||
etc.${filename}.source = format.generate "config.toml" cfg.settings;
|
||||
};
|
||||
|
||||
programs.fht-compositor = {
|
||||
enable = true;
|
||||
package =
|
||||
inputs.fht-compositor.packages.${pkgs.stdenv.hostPlatform.system}.default.overrideAttrs
|
||||
(old: {
|
||||
patches = (old.patches or [ ]) ++ [
|
||||
./resize-tiled-windows.patch
|
||||
./lone-modifier.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.makeWrapper ];
|
||||
|
||||
postInstall = (old.postInstall or "") + ''
|
||||
wrapProgram $out/bin/fht-compositor \
|
||||
--add-flags "-c /etc/${filename}"
|
||||
'';
|
||||
});
|
||||
|
||||
sessionPrograms.wallpaper = "${lib.getExe pkgs.swaybg} -i ${../../../../background.jpg} -m fill";
|
||||
|
||||
settings = {
|
||||
autostart = [ "session-programs" ];
|
||||
|
||||
general = {
|
||||
focus-follows-mouse = true;
|
||||
inner-gaps = 10;
|
||||
};
|
||||
|
||||
decorations = {
|
||||
border = {
|
||||
thickness = 4;
|
||||
radius = 12;
|
||||
};
|
||||
blur.disable = true;
|
||||
};
|
||||
|
||||
keybinds = {
|
||||
Alt-Tab = "focus-next-window";
|
||||
Super-q = "close-focused-window";
|
||||
Super-f = "fullscreen-focused-window";
|
||||
Super-Ctrl-q = "quit";
|
||||
Super-Ctrl-r = {
|
||||
action = "run-command";
|
||||
arg = "fht-compositor ipc action reload-config; session-programs";
|
||||
};
|
||||
|
||||
Print = {
|
||||
action = "run-command";
|
||||
arg = "${lib.getExe pkgs.grim} -g \"$(${lib.getExe pkgs.slurp})\" - | gradia";
|
||||
};
|
||||
|
||||
Super-t = {
|
||||
action = "run-command";
|
||||
arg = "ptyxis --new-window";
|
||||
};
|
||||
Super-e = {
|
||||
action = "run-command";
|
||||
arg = "nautilus";
|
||||
};
|
||||
Super-c = {
|
||||
action = "run-command";
|
||||
arg = "codium";
|
||||
};
|
||||
Super-b = {
|
||||
action = "run-command";
|
||||
arg = "librewolf";
|
||||
};
|
||||
|
||||
Super-Down = {
|
||||
action = "change-window-proportion";
|
||||
arg = 0.5;
|
||||
};
|
||||
Super-Up = {
|
||||
action = "change-window-proportion";
|
||||
arg = -0.5;
|
||||
};
|
||||
Super-Left = {
|
||||
action = "change-mwfact";
|
||||
arg = -0.1;
|
||||
};
|
||||
Super-Right = {
|
||||
action = "change-mwfact";
|
||||
arg = 0.1;
|
||||
};
|
||||
}
|
||||
// builtins.listToAttrs (
|
||||
builtins.genList (i: {
|
||||
name = "Super-${toString (i + 1)}";
|
||||
value = {
|
||||
action = "focus-workspace";
|
||||
arg = i;
|
||||
};
|
||||
}) 9
|
||||
);
|
||||
|
||||
mousebinds = {
|
||||
Super-Left = "swap-tile";
|
||||
# Works on tiled windows too (patched in, see resize-tiled-windows.patch)
|
||||
Super-Right = "resize-tile";
|
||||
Super-wheeldown = "focus-previous-workspace";
|
||||
Super-wheelup = "focus-next-workspace";
|
||||
};
|
||||
|
||||
input.touchpad = {
|
||||
natural-scrolling = true;
|
||||
click-method = "clickfinger";
|
||||
};
|
||||
|
||||
gesturebinds = {
|
||||
focus-next-workspace = {
|
||||
fingers = 3;
|
||||
direction = "left";
|
||||
min-swipe-distance = 1;
|
||||
};
|
||||
|
||||
focus-previous-workspace = {
|
||||
fingers = 3;
|
||||
direction = "right";
|
||||
min-swipe-distance = 1;
|
||||
};
|
||||
};
|
||||
|
||||
rules = [
|
||||
{
|
||||
match-app-id = [ ".*" ];
|
||||
floating = false;
|
||||
}
|
||||
];
|
||||
|
||||
outputs = {
|
||||
HDMI-A-1.position.x = 0;
|
||||
DP-3.position.x = 1920;
|
||||
};
|
||||
|
||||
cursor = {
|
||||
name = "GoogleDot-Blue";
|
||||
size = 24;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
83
modules/desktop/wm/fht-compositor/lone-modifier.patch
Normal file
83
modules/desktop/wm/fht-compositor/lone-modifier.patch
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
--- a/src/state.rs
|
||||
+++ b/src/state.rs
|
||||
@@ -724,6 +724,9 @@
|
||||
// We store both the timer and the keysym used to trigger the key action.
|
||||
// When we remove the keysym from suppressed keys we stop it.
|
||||
pub repeated_keyaction_timer: Option<(RegistrationToken, Keysym)>,
|
||||
+ // A modifier key that was pressed on its own, with no other key, button or scroll since.
|
||||
+ // Keybinds on just a modifier key (e.g. `Super_L`) run when it's released in that state.
|
||||
+ pub lone_modifier: Option<Keysym>,
|
||||
// To focus a layer-surface with an OnDemand keyboard exclusivity mode, the user must click
|
||||
// on the layer surface. Then, when we update the keyboard focus, we check against the clicked
|
||||
// layer surface
|
||||
@@ -962,6 +965,7 @@
|
||||
clock,
|
||||
suppressed_keys: HashMap::new(),
|
||||
repeated_keyaction_timer: None,
|
||||
+ lone_modifier: None,
|
||||
seat,
|
||||
devices: vec![],
|
||||
seat_state,
|
||||
--- a/src/input/mod.rs
|
||||
+++ b/src/input/mod.rs
|
||||
@@ -244,6 +244,7 @@
|
||||
})
|
||||
.map(|inhibitor| inhibitor.is_active())
|
||||
.unwrap_or(false);
|
||||
+ let mut lone_modifier_action = None;
|
||||
let action = keyboard.input(
|
||||
self,
|
||||
keycode,
|
||||
@@ -272,6 +273,20 @@
|
||||
return FilterResult::Forward;
|
||||
}
|
||||
|
||||
+ // Lone modifier taps. The key release is still forwarded to clients, and the
|
||||
+ // action is run after the input is processed.
|
||||
+ if let Some(raw) = raw {
|
||||
+ if key_state == KeyState::Pressed {
|
||||
+ state.fht.lone_modifier = raw.is_modifier_key().then_some(raw);
|
||||
+ } else if state.fht.lone_modifier.take() == Some(raw) {
|
||||
+ lone_modifier_action = find_keyaction(
|
||||
+ &state.fht.config.keybinds,
|
||||
+ &ModifiersState::default(),
|
||||
+ raw,
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
// Handle repeating keybinds
|
||||
// FIXME: handle this properly, this breaks if there are two repeating keybinds
|
||||
if key_state == KeyState::Released {
|
||||
@@ -331,6 +346,9 @@
|
||||
if let Some((key_pattern, key_action)) = action {
|
||||
self.process_key_action(key_action, key_pattern);
|
||||
}
|
||||
+ if let Some((key_pattern, key_action)) = lone_modifier_action {
|
||||
+ self.process_key_action(key_action, key_pattern);
|
||||
+ }
|
||||
}
|
||||
|
||||
fn on_pointer_motion<B: InputBackend>(&mut self, event: B::PointerMotionEvent) {
|
||||
@@ -505,6 +523,11 @@
|
||||
let state = wl_pointer::ButtonState::from(event.state());
|
||||
let pointer = self.fht.pointer.clone();
|
||||
|
||||
+ if state == wl_pointer::ButtonState::Pressed {
|
||||
+ // e.g. Super+click shouldn't count as a lone Super tap
|
||||
+ self.fht.lone_modifier = None;
|
||||
+ }
|
||||
+
|
||||
if state == wl_pointer::ButtonState::Pressed && !pointer.is_grabbed() {
|
||||
let pointer_loc = pointer.current_location();
|
||||
let focus = self.fht.get_pointer_focus(pointer_loc);
|
||||
@@ -555,6 +578,9 @@
|
||||
}
|
||||
|
||||
fn on_pointer_axis<B: InputBackend>(&mut self, event: B::PointerAxisEvent) {
|
||||
+ // e.g. Super+scroll shouldn't count as a lone Super tap
|
||||
+ self.fht.lone_modifier = None;
|
||||
+
|
||||
let horizontal_amount_discrete = event.amount_v120(Axis::Horizontal);
|
||||
let vertical_amount_discrete = event.amount_v120(Axis::Vertical);
|
||||
let horizontal_amount = event
|
||||
191
modules/desktop/wm/fht-compositor/resize-tiled-windows.patch
Normal file
191
modules/desktop/wm/fht-compositor/resize-tiled-windows.patch
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
--- a/src/space/workspace.rs
|
||||
+++ b/src/space/workspace.rs
|
||||
@@ -59,6 +59,11 @@
|
||||
window: Window,
|
||||
initial_window_geometry: Rectangle<i32, Logical>,
|
||||
edges: ResizeEdge,
|
||||
+ /// The layout values when the resize started, used when resizing a tiled window.
|
||||
+ initial_mwfact: f64,
|
||||
+ initial_proportion: f64,
|
||||
+ /// The sum of the proportions of the other tiles in the window's stack.
|
||||
+ initial_peers_proportion: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -2009,23 +2014,70 @@
|
||||
return false;
|
||||
};
|
||||
|
||||
- match (window.tiled(), self.current_layout()) {
|
||||
- (_, WorkspaceLayout::Floating) | (false, _) => (),
|
||||
- // We only do interactive resizes on floating windows
|
||||
- (true, _) => return false,
|
||||
- }
|
||||
-
|
||||
+ // Tiled windows are resized by changing the layout (see handle_interactive_resize_motion)
|
||||
let loc = tile.visual_location();
|
||||
let size = window.size();
|
||||
+ let initial_proportion = tile.proportion();
|
||||
+ let initial_peers_proportion = self
|
||||
+ .stack_peers(window)
|
||||
+ .into_iter()
|
||||
+ .map(|idx| self.tiles[idx].proportion())
|
||||
+ .sum();
|
||||
self.interactive_resize = Some(InteractiveResize {
|
||||
window: window.clone(),
|
||||
initial_window_geometry: Rectangle::new(loc, size),
|
||||
edges,
|
||||
+ initial_mwfact: self.mwfact,
|
||||
+ initial_proportion,
|
||||
+ initial_peers_proportion,
|
||||
});
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
+ /// Get the indices of the other tiles that share a stack with this window in the current layout,
|
||||
+ /// IE. that split the stack's length with it according to their proportions.
|
||||
+ fn stack_peers(&self, window: &Window) -> Vec<usize> {
|
||||
+ // Matches how arrange_tiles orders and splits tiles.
|
||||
+ let tiled: Vec<usize> = (0..self.tiles.len())
|
||||
+ .filter(|&idx| {
|
||||
+ let window = self.tiles[idx].window();
|
||||
+ window.tiled() && !window.maximized()
|
||||
+ })
|
||||
+ .collect();
|
||||
+ let Some(position) = tiled
|
||||
+ .iter()
|
||||
+ .position(|&idx| self.tiles[idx].window() == window)
|
||||
+ else {
|
||||
+ return vec![];
|
||||
+ };
|
||||
+
|
||||
+ let nmaster = self.nmaster.min(tiled.len());
|
||||
+ let layout = self.current_layout();
|
||||
+ let same_stack = |other: usize| match layout {
|
||||
+ WorkspaceLayout::Tile | WorkspaceLayout::BottomStack => {
|
||||
+ (position < nmaster) == (other < nmaster)
|
||||
+ }
|
||||
+ // The non-master tiles alternate between the left and right stacks
|
||||
+ WorkspaceLayout::CenteredMaster => {
|
||||
+ if position < nmaster {
|
||||
+ other < nmaster
|
||||
+ } else {
|
||||
+ other >= nmaster && (other - nmaster) % 2 == (position - nmaster) % 2
|
||||
+ }
|
||||
+ }
|
||||
+ // The other layouts don't use proportions
|
||||
+ _ => false,
|
||||
+ };
|
||||
+
|
||||
+ tiled
|
||||
+ .into_iter()
|
||||
+ .enumerate()
|
||||
+ .filter(|&(other, _)| other != position && same_stack(other))
|
||||
+ .map(|(_, idx)| idx)
|
||||
+ .collect()
|
||||
+ }
|
||||
+
|
||||
/// Handle an interactive resize grab motion.
|
||||
///
|
||||
/// `delta` is how much the cursor moved from its initial window location.
|
||||
@@ -2052,11 +2104,53 @@
|
||||
return None;
|
||||
}
|
||||
|
||||
- match (window.tiled(), self.current_layout()) {
|
||||
- (_, WorkspaceLayout::Floating) | (false, _) => (),
|
||||
- // We switched from floating to tiled between the motion events
|
||||
- // Can happen if the user uses a key action bound to toggle-window-floating
|
||||
- (true, _) => return None,
|
||||
+ let layout = self.current_layout();
|
||||
+ if window.tiled() && layout != WorkspaceLayout::Floating {
|
||||
+ // For tiled windows, dragging along the master/stack split moves the split (mwfact)
|
||||
+ // so it follows the cursor, and dragging across it grows/shrinks the window in its
|
||||
+ // stack (proportion). Which axis is which depends on the layout.
|
||||
+ let initial_size = interactive_resize.initial_window_geometry.size;
|
||||
+ let work_area_size = self.work_area.size;
|
||||
+ let (split_delta, split_length, stack_delta, stack_length, grow_edge) = match layout {
|
||||
+ WorkspaceLayout::BottomStack => {
|
||||
+ (delta.y, work_area_size.h, delta.x, initial_size.w, ResizeEdge::LEFT)
|
||||
+ }
|
||||
+ _ => (delta.x, work_area_size.w, delta.y, initial_size.h, ResizeEdge::TOP),
|
||||
+ };
|
||||
+ // Grabbing the top (or left) part of the window grows it in that direction instead
|
||||
+ let stack_delta = if interactive_resize.edges.intersects(grow_edge) {
|
||||
+ -stack_delta
|
||||
+ } else {
|
||||
+ stack_delta
|
||||
+ };
|
||||
+
|
||||
+ let mwfact =
|
||||
+ interactive_resize.initial_mwfact + f64::from(split_delta) / f64::from(split_length.max(1));
|
||||
+
|
||||
+ // Solve for the proportion that gives the window exactly the length it was dragged to.
|
||||
+ // The other tiles in the stack keep their proportions (`peers`) during the drag, and
|
||||
+ // the window's length is `total * p / (p + peers)`, so `p = len * peers / (total - len)`
|
||||
+ let initial_proportion = interactive_resize.initial_proportion;
|
||||
+ let peers = interactive_resize.initial_peers_proportion;
|
||||
+ // Nothing to resize against if the window is alone in its stack
|
||||
+ if peers > 0.0 && initial_proportion > 0.0 && stack_length > 0 {
|
||||
+ let initial_length = f64::from(stack_length);
|
||||
+ let total_length = initial_length * (initial_proportion + peers) / initial_proportion;
|
||||
+ // Always leave some room for the window and the other tiles in the stack
|
||||
+ let min_length = (total_length * 0.05).max(1.0);
|
||||
+ let peer_count = self.stack_peers(window).len() as f64;
|
||||
+ let max_length = (total_length - min_length * peer_count.max(1.0)).max(min_length);
|
||||
+ let length = (initial_length + f64::from(stack_delta)).clamp(min_length, max_length);
|
||||
+ let proportion = length * peers / (total_length - length);
|
||||
+
|
||||
+ if let Some(tile) = self.tiles.iter_mut().find(|tile| tile.window() == window) {
|
||||
+ tile.set_proportion(proportion);
|
||||
+ }
|
||||
+ }
|
||||
+ // This also re-arranges the tiles
|
||||
+ self.set_mwfact(mwfact, false);
|
||||
+
|
||||
+ return Some(true);
|
||||
}
|
||||
|
||||
let mut new_size = interactive_resize.initial_window_geometry.size;
|
||||
@@ -2140,6 +2234,24 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // Rescale the proportions in the window's stack so they average out to 1. This keeps the
|
||||
+ // same layout, but stops the values from drifting to extremes over repeated resizes,
|
||||
+ // where fixed steps (like change-window-proportion) would barely do anything anymore.
|
||||
+ if window.tiled() && self.current_layout() != WorkspaceLayout::Floating {
|
||||
+ let mut stack = self.stack_peers(window);
|
||||
+ if let Some(idx) = self.tiles.iter().position(|tile| tile.window() == window) {
|
||||
+ stack.push(idx);
|
||||
+ }
|
||||
+ let total: f64 = stack.iter().map(|&idx| self.tiles[idx].proportion()).sum();
|
||||
+ if stack.len() > 1 && total > 0.0 {
|
||||
+ let factor = stack.len() as f64 / total;
|
||||
+ for idx in stack {
|
||||
+ let proportion = self.tiles[idx].proportion();
|
||||
+ self.tiles[idx].set_proportion(proportion * factor);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
true
|
||||
}
|
||||
|
||||
--- a/src/input/actions.rs
|
||||
+++ b/src/input/actions.rs
|
||||
@@ -605,12 +605,8 @@
|
||||
}
|
||||
MouseAction::ResizeTile => {
|
||||
if let Some(window) = focus.and_then(|focus| focus.window) {
|
||||
+ // Tiled windows are resized too, by changing the workspace layout
|
||||
let workspace = self.fht.space.workspace_for_window(&window).unwrap();
|
||||
- match (window.tiled(), workspace.current_layout()) {
|
||||
- (_, WorkspaceLayout::Floating) | (false, _) => (),
|
||||
- // We only do interactive resizes on floating windows
|
||||
- (true, _) => return,
|
||||
- }
|
||||
|
||||
let pointer_loc = self.fht.pointer.current_location();
|
||||
let loc = self.fht.space.window_location(&window).unwrap().to_f64();
|
||||
74
modules/desktop/wm/launcher.nix
Normal file
74
modules/desktop/wm/launcher.nix
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
environment.etc = {
|
||||
"xdg/walker/config.toml".source = (pkgs.formats.toml { }).generate "walker.toml" {
|
||||
force_keyboard_focus = true;
|
||||
theme = "system";
|
||||
};
|
||||
|
||||
"xdg/walker/themes/system/style.css".source = pkgs.runCommand "walker-system-style.css" { } ''
|
||||
sed '/^@define-color/d' ${pkgs.walker.src}/resources/themes/default/style.css > $out
|
||||
'';
|
||||
|
||||
"xdg/elephant/elephant.toml".source = (pkgs.formats.toml { }).generate "elephant.toml" {
|
||||
terminal_cmd = "ptyxis -x";
|
||||
ignored_providers = [
|
||||
"1password"
|
||||
"aptpackages"
|
||||
"archlinuxpkgs"
|
||||
"bitwarden"
|
||||
"bluetooth"
|
||||
"bookmarks"
|
||||
"clipboard"
|
||||
"dnfpackages"
|
||||
"files"
|
||||
"menus"
|
||||
"niriactions"
|
||||
"nirisessions"
|
||||
"playerctl"
|
||||
"protonpass"
|
||||
"providerlist"
|
||||
"runner"
|
||||
"snippets"
|
||||
"symbols"
|
||||
"todo"
|
||||
"unicode"
|
||||
"windows"
|
||||
"wireplumber"
|
||||
];
|
||||
};
|
||||
|
||||
"xdg/elephant/websearch.toml".source =
|
||||
let
|
||||
inherit (config.programs.firefox.policies) SearchEngines;
|
||||
in
|
||||
(pkgs.formats.toml { }).generate "websearch.toml" {
|
||||
entries = map (
|
||||
engine:
|
||||
{
|
||||
name = engine.Name;
|
||||
url = lib.replaceStrings [ "{searchTerms}" ] [ "%TERM%" ] engine.URLTemplate;
|
||||
default = engine.Name == SearchEngines.Default;
|
||||
}
|
||||
// lib.optionalAttrs (engine ? Alias) { prefix = "${engine.Alias} "; }
|
||||
) SearchEngines.Add;
|
||||
};
|
||||
};
|
||||
|
||||
programs.fht-compositor = {
|
||||
sessionPrograms = {
|
||||
elephant = lib.getExe pkgs.elephant;
|
||||
walker = "walker --gapplication-service";
|
||||
};
|
||||
|
||||
settings.keybinds.Super_L = {
|
||||
action = "run-command";
|
||||
arg = "walker";
|
||||
};
|
||||
};
|
||||
}
|
||||
52
modules/desktop/wm/lockscreen.nix
Normal file
52
modules/desktop/wm/lockscreen.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
services.logind.settings.Login.HandlePowerKey = "suspend";
|
||||
|
||||
programs = {
|
||||
hyprlock.enable = true;
|
||||
|
||||
fht-compositor.sessionPrograms.hypridle =
|
||||
"${lib.getExe pkgs.hypridle} --config ${pkgs.writeText "hypridle.conf" ''
|
||||
general {
|
||||
lock_cmd = pidof hyprlock || ${lib.getExe pkgs.hyprlock} --config ${
|
||||
let
|
||||
inherit (config.lib.stylix) colors;
|
||||
in
|
||||
pkgs.writeText "hyprlock.conf" ''
|
||||
background {
|
||||
path = screenshot
|
||||
blur_passes = 3
|
||||
}
|
||||
|
||||
label {
|
||||
text = $TIME
|
||||
font_size = 96
|
||||
position = 0, 200
|
||||
}
|
||||
|
||||
label {
|
||||
text = cmd[update:60000] date +"%A, %B %-d"
|
||||
font_size = 20
|
||||
position = 0, 110
|
||||
}
|
||||
|
||||
input-field {
|
||||
size = 300, 50
|
||||
outline_thickness = 0
|
||||
inner_color = rgb(${colors.base01})
|
||||
font_color = rgb(${colors.base05})
|
||||
check_color = rgb(${colors.base0D})
|
||||
fade_on_empty = false
|
||||
}
|
||||
''
|
||||
}
|
||||
before_sleep_cmd = loginctl lock-session
|
||||
}
|
||||
''}";
|
||||
};
|
||||
}
|
||||
76
modules/desktop/wm/notifications.nix
Normal file
76
modules/desktop/wm/notifications.nix
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
{ pkgs, lib, ... }:
|
||||
let
|
||||
swaync = pkgs.swaynotificationcenter;
|
||||
in
|
||||
{
|
||||
programs.fht-compositor.sessionPrograms.swaync =
|
||||
"${lib.getExe' swaync "swaync"} --style ${pkgs.writeText "swaync.css" ''
|
||||
@import url("file://${swaync}/etc/xdg/swaync/style.css");
|
||||
|
||||
:root {
|
||||
--noti-bg-focus: transparent;
|
||||
--noti-border-color: transparent;
|
||||
--notification-shadow: none;
|
||||
--border-radius: 16px;
|
||||
--notification-icon-size: 48px;
|
||||
--font-size-summary: 14px;
|
||||
--font-size-body: 14px;
|
||||
}
|
||||
|
||||
.control-center {
|
||||
background: shade(@theme_bg_color, 1.1);
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification,
|
||||
.notification-group.collapsed .notification-row .notification {
|
||||
background: shade(@theme_bg_color, 1.25);
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification .notification-default-action:hover,
|
||||
.control-center .control-center-list .notification .notification-default-action:hover,
|
||||
.notification-group.collapsed:hover .notification-row:not(:only-child) .notification {
|
||||
background: shade(@theme_bg_color, 1.4);
|
||||
}
|
||||
|
||||
.control-center .control-center-list-placeholder {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification .notification-default-action .notification-content {
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification .notification-default-action .notification-content .text-box .time {
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.notification-row .notification-background .notification .notification-default-action .notification-content .text-box .body {
|
||||
opacity: 0.8;
|
||||
}
|
||||
''} --config ${
|
||||
(pkgs.formats.json { }).generate "swaync.json" (
|
||||
let
|
||||
default = lib.importJSON "${swaync}/etc/xdg/swaync/config.json";
|
||||
in
|
||||
default
|
||||
// lib.genAttrs (map (side: "control-center-margin-${side}") [
|
||||
"top"
|
||||
"bottom"
|
||||
"right"
|
||||
]) (_: 8)
|
||||
// {
|
||||
notification-window-width = 420;
|
||||
ignore-gtk-theme = false;
|
||||
fit-to-screen = false;
|
||||
control-center-height = -1;
|
||||
widget-config = default.widget-config // {
|
||||
notifications = default.widget-config.notifications or { } // {
|
||||
vexpand = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
}";
|
||||
}
|
||||
26
modules/desktop/wm/osd.nix
Normal file
26
modules/desktop/wm/osd.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ pkgs, lib, ... }:
|
||||
{
|
||||
programs.fht-compositor = {
|
||||
sessionPrograms.swayosd = "${lib.getExe' pkgs.swayosd "swayosd-server"} --style ${pkgs.writeText "swayosd.css" ''
|
||||
@import url("file://${pkgs.swayosd}/etc/xdg/swayosd/style.css");
|
||||
|
||||
window#osd {
|
||||
background: shade(@theme_bg_color, 1.15);
|
||||
}
|
||||
''}";
|
||||
|
||||
settings.keybinds =
|
||||
lib.mapAttrs
|
||||
(_: args: {
|
||||
action = "run-command";
|
||||
arg = "${lib.getExe' pkgs.swayosd "swayosd-client"} ${args}";
|
||||
repeat = true;
|
||||
})
|
||||
{
|
||||
XF86AudioRaiseVolume = "--output-volume raise";
|
||||
XF86AudioLowerVolume = "--output-volume lower";
|
||||
XF86AudioMute = "--output-volume mute-toggle";
|
||||
XF86AudioMicMute = "--input-volume mute-toggle";
|
||||
};
|
||||
};
|
||||
}
|
||||
4
modules/desktop/wm/panel.nix
Normal file
4
modules/desktop/wm/panel.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
# gaypanel itself is configured in wrappers/desktop/gaypanel
|
||||
programs.fht-compositor.sessionPrograms.gaypanel = "gaypanel";
|
||||
}
|
||||
Loading…
Reference in a new issue