minimise nesting in /home

This commit is contained in:
xunuwu 2025-06-06 12:58:39 +02:00
parent caa2a3d7c5
commit 383d9f878e
Signed by: xun
SSH key fingerprint: SHA256:Uot/1WoAjWAeqLOHA5vYy4phhVydsH7jCPmBjaPZfgI
37 changed files with 40 additions and 45 deletions

View file

@ -0,0 +1,16 @@
{
lib,
pkgs,
...
}: {
programs.fuzzel = {
enable = true;
settings = {
main = {
terminal = "${lib.getExe pkgs.foot}";
layer = "overlay";
dpi-aware = false;
};
};
};
}

View file

@ -0,0 +1,5 @@
{pkgs, ...}: {
home.packages = with pkgs; [
wl-clipboard
];
}

View file

@ -0,0 +1,5 @@
{
services.wob = {
enable = true;
};
}

View file

@ -0,0 +1,155 @@
{
config,
pkgs,
lib,
osConfig,
...
}: {
imports = [
../common/fuzzel.nix
../common/wob.nix
../common/wl-clipboard.nix
./waybar.nix
];
# services.gnome-keyring = {
# enable = true;
# components = ["secrets"];
# };
services.cliphist = {
enable = true;
systemdTargets = ["sway-session.target"];
extraOptions = ["-max-items" "150"];
};
# notification center
services.swaync = {
enable = true;
settings = {
timeout = 4;
positionX = "right";
positionY = "top";
layer = "overlay";
control-center-layer = "top";
layer-shell = true;
cssPriority = "application";
control-center-margin-top = 0;
control-center-margin-bottom = 0;
control-center-margin-right = 0;
control-center-margin-left = 0;
notification-2fa-action = true;
notification-inline-replies = false;
notification-icon-size = 64;
notification-body-image-height = 100;
notification-body-image-width = 200;
};
};
wayland.systemd.target = "sway-session.target";
wayland.windowManager.sway = {
enable = true;
checkConfig = true; # doesnt work with custom wallpaper
extraSessionCommands = ''
export SDL_VIDEODRIVER=wayland,x11,windows
export NIXOS_OZONE_WL=1
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export _JAVA_AWT_WM_NONREPARENTING=1
'';
config = {
modifier = "Mod4";
input."type:keyboard".xkb_layout = osConfig.services.xserver.xkb.layout;
bars = []; # i use waybar instead
window = {
titlebar = false;
};
floating.criteria = [
{
app_id = "org.keepassxc.KeePassXC";
title = "^KeePassXC - "; # should only match popups
}
];
menu = "${lib.getExe pkgs.fuzzel}";
keybindings = let
mod = config.wayland.windowManager.sway.config.modifier;
wobVolume = "${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_SINK@ | awk '{print $2*100}' > $XDG_RUNTIME_DIR/wob.sock";
setVolume = limit: amount: "${pkgs.wireplumber}/bin/wpctl set-volume -l ${limit} @DEFAULT_AUDIO_SINK@ ${amount}";
monitorId = pkgs.writers.writeBash "monitor-id" ''
swaymsg -t get_outputs \
| ${lib.getExe pkgs.jq} -r '.[] | select (.focused == true).name' \
| ${lib.getExe pkgs.perl} -ne '$s=0;for(split//){$s+=ord}print"$s"'
'';
pauseApp = pkgs.writers.writeBash "pause-app" ''
set -e
pid=$(swaymsg -t get_tree \
| ${lib.getExe pkgs.jq} -re '.. | select (.type? == "con" and .focused? == true).pid')
if [ $(cat "/proc/$pid/wchan") == "do_signal_stop" ]; then
kill -s SIGCONT $pid
else
kill -s SIGSTOP $pid
fi
'';
dir = {
inherit (config.wayland.windowManager.sway.config) up down left right;
};
in
lib.mkOptionDefault (
{
"${mod}+n" = "exec ${pkgs.swaynotificationcenter}/bin/swaync-client -t";
"${mod}+Shift+v" = "exec ${lib.getExe pkgs.cliphist} list | ${lib.getExe pkgs.wofi} --dmenu | ${lib.getExe pkgs.cliphist} decode | ${pkgs.wl-clipboard}/bin/wl-copy";
"${mod}+Ctrl+${dir.left}" = "focus output left";
"${mod}+Ctrl+${dir.right}" = "focus output right";
"${mod}+Ctrl+${dir.up}" = "focus output up";
"${mod}+Ctrl+${dir.down}" = "focus output down";
"${mod}+Ctrl+Shift+${dir.left}" = "move output left";
"${mod}+Ctrl+Shift+${dir.right}" = "move output right";
"${mod}+Ctrl+Shift+${dir.up}" = "move output up";
"${mod}+Ctrl+Shift+${dir.down}" = "move output down";
"${mod}+Shift+t" = "sticky toggle";
"${mod}+Shift+Backspace" = "exec systemctl suspend";
"${mod}+Shift+s" = "exec ${lib.getExe pkgs.wayfreeze} --after-freeze-cmd '${lib.getExe pkgs.sway-contrib.grimshot} copy anything && pkill wayfreeze'";
"${mod}+Ctrl+Shift+s" = "exec ${lib.getExe pkgs.wayfreeze} --after-freeze-cmd '${lib.getExe pkgs.sway-contrib.grimshot} savecopy anything && pkill wayfreeze'";
# "${mod}+Alt+s" = "exec ${lib.getExe pkgs.wayfreeze} --after-freeze-cmd '${lib.getExe pkgs.sway-contrib.grimshot} save anything - | ${lib.getExe pkgs.tesseract} -l eng - - | wl-copy && pkill wayfreeze'";
"${mod}+Alt+s" = "exec ${lib.getExe pkgs.wayfreeze} --after-freeze-cmd '${lib.getExe pkgs.sway-contrib.grimshot} save anything - && pkill wayfreeze' | ${lib.getExe pkgs.satty} --disable-notifications --fullscreen -f -";
"${mod}+Shift+p" = "exec ${pauseApp}";
"${mod}+period" = "exec ${lib.getExe pkgs.bemoji}";
"XF86AudioRaiseVolume" = "exec ${setVolume "1.5" "3%+"} && ${wobVolume}";
"XF86AudioLowerVolume" = "exec ${setVolume "1.5" "3%-"} && ${wobVolume}";
"XF86AudioPlay" = "exec ${lib.getExe pkgs.playerctl} play-pause";
"XF86AudioStop" = "exec ${lib.getExe pkgs.playerctl} stop";
"XF86AudioNext" = "exec ${lib.getExe pkgs.playerctl} next";
"XF86AudioPrev" = "exec ${lib.getExe pkgs.playerctl} previous";
"XF86AudioMute" = "exec ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SINK@ toggle";
}
// (let
inherit (builtins) foldl';
inherit (lib) range;
in
foldl' (acc: x:
acc
// (let
y = toString x;
in {
"${mod}+${y}" = "exec swaymsg workspace number \"$(${monitorId})${y}:${y}\"";
"${mod}+Shift+${y}" = "exec swaymsg move container to workspace number \"$(${monitorId})${y}:${y}\"";
}))
{}
(range 0 9))
);
};
extraConfig = ''
bindcode 202 exec ${lib.getExe pkgs.obs-cmd} replay save # F24/numpad 1 on my ID75
'';
};
}

View file

@ -0,0 +1,16 @@
diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp
index 8f273300..faed503c 100644
--- a/src/modules/sway/workspaces.cpp
+++ b/src/modules/sway/workspaces.cpp
@@ -343,9 +343,9 @@ auto Workspaces::update() -> void {
fmt::arg("output", (*it)["output"].asString()));
}
if (!config_["disable-markup"].asBool()) {
- static_cast<Gtk::Label *>(button.get_children()[0])->set_markup(output);
+ static_cast<Gtk::Label *>(button.get_children()[0])->set_markup(trimWorkspaceName(output));
} else {
- button.set_label(output);
+ button.set_label(trimWorkspaceName(output));
}
onButtonReady(*it, button);
}

View file

@ -0,0 +1,39 @@
{pkgs, ...}: {
programs.waybar = {
enable = true;
package = pkgs.waybar.overrideAttrs (final: prev: {
patches = [./waybar-workspace.patch];
});
settings = [
{
height = 24;
spacing = 4;
position = "top";
modules-left = [
"sway/workspaces"
];
modules-center = [
"sway/window"
];
modules-right = [
"tray"
"clock"
];
"sway/workspaces" = {
format = "{icon}";
};
"sway/window" = {
max-length = 80;
};
clock = {
format = "{:%V|%d %a %H:%M}";
tooltip-format = "<big>{:%a %Y-%m-%d %H:%M}</big>\n<small>{calendar}</small>";
};
}
];
systemd = {
enable = true;
target = "sway-session.target";
};
};
}

40
home/desktop/theme.nix Normal file
View file

@ -0,0 +1,40 @@
{pkgs, ...}: {
home.pointerCursor = {
gtk.enable = true;
x11.enable = true;
package = pkgs.apple-cursor;
name = "macOS-BigSur";
size = 16;
};
# Also sets org.freedesktop.appearance color-scheme
# dconf.settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
gtk = {
enable = true;
# theme = {
# package = pkgs.gnome-themes-extra;
# name = "Adwaita-dark";
# };
# iconTheme = {
# package = pkgs.adwaita-icon-theme;
# name = "Adwaita-dark";
# };
font = {
name = "Sans";
size = 11;
};
# gtk2.extraConfig = "gtk-application-prefer-dark-theme=1";
# gtk3.extraConfig.gtk-application-prefer-dark-theme = 1;
# gtk4.extraConfig.gtk-application-prefer-dark-theme = 1;
};
qt = {
enable = true;
# platformTheme.name = "gtk3";
# style = {
# name = "Adwaita-dark";
# package = pkgs.adwaita-qt;
# };
};
}

View file

@ -0,0 +1,16 @@
{pkgs, ...}: {
xdg.portal = {
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-wlr
xdg-desktop-portal-gtk
];
config = {
preferred = {
default = "gtk";
"org.freedesktop.impl.portal.Screenshot" = "wlr";
"org.freedesktop.impl.portal.Screencast" = "wlr";
};
};
};
}