add sway and xdg config

This commit is contained in:
Fabian Montero 2025-08-05 21:58:46 -06:00
parent 9687235d30
commit ef8939612e
Signed by: fabian
GPG key ID: 1FFAC35E1798174F
5 changed files with 144 additions and 0 deletions

View file

@ -84,6 +84,7 @@ in {
./startx.nix
./picom.nix
./theme.nix
./sway.nix
];
config = let

109
home/modules/gui/sway.nix Normal file
View file

@ -0,0 +1,109 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.local.gui;
in {
config = mkIf cfg.enable {
home.packages = [
pkgs.wlr-randr
];
programs = {
waybar.enable = true;
wofi.enable = true;
};
services = {
swayidle = {
enable = true;
timeouts = [
{
timeout = 600;
command = "${getExe pkgs.gtklock} -d";
}
];
};
};
systemd.user.services.wl-gammarelay-rs = {
Unit.After = ["sway-session.target"];
Install.WantedBy = ["sway-session.target"];
Service.ExecStart = getExe pkgs.wl-gammarelay-rs;
};
wayland.windowManager.sway = {
enable = true;
config = {
modifier = "Mod4";
focus.followMouse = true;
fonts = {
size = 11.0;
names = ["DejaVu Sans Mono"];
style = "Bold Semi-Condensed";
};
bars = singleton {
command = "waybar";
position = "top";
};
keybindings = let
mod = config.wayland.windowManager.sway.config.modifier;
wofi = config.programs.wofi.package;
grimshot = getExe pkgs.sway-contrib.grimshot;
in
mkOptionDefault {
"${mod}+a" = "focus parent";
"${mod}+c" = "focus child";
"${mod}+d" = "exec --no-startup-id ${getExe wofi} -S run";
"${mod}+i" = "exec busctl --user call rs.wl-gammarelay / rs.wl.gammarelay ToggleInverted";
"${mod}+o" = "exec ${getExe pkgs.gtklock} -d";
"${mod}+Return" = "exec ${lib.getExe pkgs.kitty} ${lib.getExe pkgs.tmux}";
"${mod}+Shift+e" = "input * xkb_layout latam";
"${mod}+Shift+u" = "input * xkb_layout us";
"${mod}+p" = "exec ${grimshot} copy active";
"${mod}+Shift+p" = "exec ${grimshot} copy area";
"${mod}+Ctrl+p" = "exec ${grimshot} copy window";
};
window.commands = [
# (No) Title Bars
{
command = "border pixel 5";
criteria.class = "^.*";
}
{
command = "floating enabled";
criteria.class = "floating";
}
];
};
extraSessionCommands = ''
export SDL_VIDEODRIVER=wayland
# needs qt5.qtwayland in systemPackages
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
# Fix for some Java AWT applications (e.g. Android Studio),
# use this if they aren't displayed properly:
export _JAVA_AWT_WM_NONREPARENTING=1
'';
swaynag.enable = true;
systemd.enable = true;
xwayland = true;
};
};
}

View file

@ -15,5 +15,6 @@
./bluetooth.nix
./net.nix
./steam.nix
./xdg.nix
];
}

32
sys/modules/xdg.nix Normal file
View file

@ -0,0 +1,32 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.local.sys.xdg;
in {
options.local.sys.xdg = {
enable = mkEnableOption "xdg settings";
};
config = mkIf cfg.enable {
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = [pkgs.xdg-desktop-portal-gtk];
xdgOpenUsePortal = true;
# warning: xdg-desktop-portal 1.17 reworked how portal implementations are loaded, you
# should either set `xdg.portal.config` or `xdg.portal.configPackages`
# to specify which portal backend to use for the requested interface.
#
# https://github.com/flatpak/xdg-desktop-portal/blob/1.18.1/doc/portals.conf.rst.in
#
# If you simply want to keep the behaviour in < 1.17, which uses the first
# portal implementation found in lexicographical order, use the following:
#
# xdg.portal.config.common.default = "*";
config.common.default = "*";
};
};
}

View file

@ -20,6 +20,7 @@
virtualisation.enable = true;
androidSupport.enable = true;
steam.enable = true;
xdg.enable = true;
users = {
fabian = {