Move window manager config (sway, hyprland) from desktop to wm directory, add GTK theme handling configs for sway, adjust wezterm theme for rounded corners

This commit is contained in:
Evie Litherland-Smith 2023-06-20 15:26:07 +01:00
parent 2f188f625a
commit 2e9e40ff36
13 changed files with 181 additions and 95 deletions

View file

@ -3,11 +3,13 @@ HOMEMANAGER_CONFIG := $(PWD)/machines/$(HOSTNAME)/$(USER).nix
CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config) CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config)
HOMEMANAGER_CONFIG_DIR := $(CONFIG_DIR)/home-manager HOMEMANAGER_CONFIG_DIR := $(CONFIG_DIR)/home-manager
.PHONY: default clean nixos home /etc/nixos/config nvim .PHONY: default all clean nixos home /etc/nixos/config nvim
default: nvim default:
command -v nix > /dev/null || exit 1 command -v nix > /dev/null || exit 1
if [ -e /etc/nixos/ ]; then make nixos; else make home; fi if [ -e /etc/nixos/ ]; then make nixos; else make home; fi
all: default nvim
bat cache --build bat cache --build
clean: clean:

View file

@ -2,12 +2,13 @@
candy-icon-theme = pkgs.callPackage ./pkgs/candy-icon-theme {}; candy-icon-theme = pkgs.callPackage ./pkgs/candy-icon-theme {};
sweet-folder-theme = pkgs.callPackage ./pkgs/sweet-folder-theme {}; sweet-folder-theme = pkgs.callPackage ./pkgs/sweet-folder-theme {};
in { in {
home.packages = [ home.packages = with pkgs; [
glib
candy-icon-theme candy-icon-theme
sweet-folder-theme sweet-folder-theme
pkgs.breeze-gtk breeze-gtk
pkgs.gnome.adwaita-icon-theme gnome.adwaita-icon-theme
pkgs.hicolor-icon-theme hicolor-icon-theme
]; ];
gtk = { gtk = {
enable = true; enable = true;
@ -24,4 +25,5 @@ in {
name = "Sweet-Dark"; name = "Sweet-Dark";
}; };
}; };
services.xsettingsd.enable = true;
} }

View file

@ -1,30 +1,27 @@
{pkgs, ...}: let {
logout-utility = pkgs.writeShellScriptBin "logout-utility" (builtins.readFile ./scripts/logout-utility); pkgs,
config,
...
}: let
powermenu = pkgs.writeShellScriptBin "powermenu" (builtins.readFile ./scripts/powermenu); powermenu = pkgs.writeShellScriptBin "powermenu" (builtins.readFile ./scripts/powermenu);
power-profiles = pkgs.writeShellScriptBin "power-profiles" (builtins.readFile ./scripts/power-profiles); power-profiles = pkgs.writeShellScriptBin "power-profiles" (builtins.readFile ./scripts/power-profiles);
icon-theme = config.gtk.iconTheme.name;
in { in {
imports = [../gui/foot.nix ./gtk.nix]; imports = [../gui/foot.nix ./gtk.nix];
home.packages = [logout-utility powermenu power-profiles]; home.packages = [powermenu power-profiles];
programs.rofi = { programs.rofi = {
enable = true; enable = true;
location = "center"; location = "center";
pass.enable = true; pass.enable = true;
terminal = "wezterm"; terminal = "wezterm";
plugins = with pkgs; [
rofi-calc
];
extraConfig = { extraConfig = {
modi = "drun"; modi = "drun";
icon-theme = "Sweet-Rainbow"; icon-theme = icon-theme;
show-icons = true; show-icons = true;
drun-display-format = "{icon} {name}"; drun-display-format = "{icon} {name}";
disable-history = false; disable-history = false;
hide-scrollbar = true; hide-scrollbar = true;
# display-drun = "  Apps ";
display-run = " Run "; display-run = " Run ";
# display-window = " 﩯 Window";
# display-calc = " √ Calculator";
# sidebar-mode = true;
}; };
theme = ./config/rofi/catppuccin-macchiato.rasi; theme = ./config/rofi/catppuccin-macchiato.rasi;
}; };

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
if [[ "$XDG_CURRENT_DESKTOP" == "Hyprland" ]]; then
hyprctl dispatch exit
elif [[ "$XDG_CURRENT_DESKTOP" == "sway" ]]; then
swaymsg exit
else
echo "Unsupported desktop environment $XDG_CURRENT_DESKTOP"
fi

0
home/desktop/scripts/power-profiles Executable file → Normal file
View file

4
home/desktop/scripts/powermenu Executable file → Normal file
View file

@ -117,8 +117,8 @@ menu=(
[ Reboot]="systemctl reboot" [ Reboot]="systemctl reboot"
[ Suspend]="systemctl suspend" [ Suspend]="systemctl suspend"
[ Hibernate]="systemctl hibernate" [ Hibernate]="systemctl hibernate"
[ Lock]="hyprctl dispatch exec swaylock" [ Lock]="swaymsg exec swaylock"
[ Logout]="logout-utility" [ Logout]="swaymsg exit"
[ Cancel]="" [ Cancel]=""
) )

View file

@ -6,6 +6,30 @@
}: let }: let
modifier = config.wayland.windowManager.sway.config.modifier; modifier = config.wayland.windowManager.sway.config.modifier;
term = config.wayland.windowManager.sway.config.terminal; term = config.wayland.windowManager.sway.config.terminal;
# currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
# the suggested way to set gtk settings is with gsettings
# for gsettings to work, we need to tell it where the schemas are
# using the XDG_DATA_DIR environment variable
# run at the end of sway config
configure-gtk = pkgs.writeTextFile {
name = "configure-gtk";
destination = "/bin/configure-gtk";
executable = true;
text = let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
gtk-theme = config.gtk.theme.name;
icon-theme = config.gtk.iconTheme.name;
cursor-theme = config.gtk.cursorTheme.name;
in ''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
gsettings set $gnome_schema gtk-theme '${gtk-theme}'
gsettings set $gnome_schema icon-theme '${icon-theme}'
gsettings set $gnome_schema cursor-theme '${cursor-theme}'
'';
};
in { in {
imports = [ imports = [
./swaylock.nix ./swaylock.nix
@ -13,8 +37,11 @@ in {
./gtk.nix ./gtk.nix
./dunst.nix ./dunst.nix
./rofi.nix ./rofi.nix
../gui/foot.nix
]; ];
home.packages = with pkgs; [ home.packages = with pkgs; [
configure-gtk
swaycons
pipewire pipewire
wireplumber wireplumber
wl-clipboard wl-clipboard
@ -24,6 +51,13 @@ in {
programs.rofi.package = pkgs.rofi-wayland; programs.rofi.package = pkgs.rofi-wayland;
wayland.windowManager.sway = { wayland.windowManager.sway = {
enable = true; enable = true;
systemd.enable = true;
wrapperFeatures.gtk = true;
xwayland = true;
extraSessionCommands = ''
export GDK_BACKEND=wayland,x11
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"'';
config = { config = {
input."*".xkb_layout = "gb"; input."*".xkb_layout = "gb";
output."*".bg = "~/nixos/wallpaper.jpg fill"; output."*".bg = "~/nixos/wallpaper.jpg fill";
@ -36,6 +70,59 @@ in {
outer = lib.mkDefault 20; outer = lib.mkDefault 20;
}; };
bars = [{command = "${pkgs.waybar}/bin/waybar";}]; bars = [{command = "${pkgs.waybar}/bin/waybar";}];
assigns = {
"2" = [{app_id = "firefox";}];
"3" = [
{app_id = "Signal";}
{app_id = "fractal";}
{app_id = "discord";}
{class = "teams-for-linux";}
];
"4" = [{class = "Nxplayer.bin";}];
};
floating.criteria = [
{app_id = "foot";}
{app_id = "pavucontrol";}
{app_id = ".blueman-manager-wrapped";}
{app_id = "otpclient";}
{app_id = "thunar";}
{app_id = "^swayimg.*$";}
{class = "Nxplayer.bin";}
];
startup = [
{
command = "dbus-sway-environment";
always = true;
}
{
command = "configure-gtk";
always = true;
}
{
command = "swaycons";
always = true;
}
{command = "dunst";}
];
modifier = lib.mkDefault "Mod1";
terminal = lib.mkDefault "${pkgs.wezterm}/bin/wezterm";
window.titlebar = false;
workspaceAutoBackAndForth = true;
keybindings = lib.mkOptionDefault {
"${modifier}+Return" = "exec ${term}";
"${modifier}+Shift+Return" = "exec ${pkgs.foot}/bin/foot";
"${modifier}+q" = "kill";
"${modifier}+e" = "exec power-profiles";
"${modifier}+p" = "exec powermenu";
"${modifier}+v" = "floating toggle";
"${modifier}+space" = "exec ${pkgs.rofi}/bin/rofi -show drun";
"${modifier}+F1" = "exec ${pkgs.swaylock}/bin/swaylock";
"${modifier}+w" = "exec ${pkgs.firefox}/bin/firefox";
"${modifier}+f" = "exec ${pkgs.xfce.thunar}/bin/thunar";
"${modifier}+m" = "fullscreen toggle";
"${modifier}+c" = "scratchpad show";
"${modifier}+Shift+c" = "move scratchpad";
};
colors = { colors = {
focused = { focused = {
border = "#4c7899"; border = "#4c7899";
@ -74,45 +161,6 @@ in {
}; };
background = "#ffffff"; background = "#ffffff";
}; };
assigns = {
"1" = [{app_id = "org.wezfurlong.wezterm";}];
"2" = [{app_id = "firefox";}];
"3" = [
{app_id = "Signal";}
{app_id = "fractal";}
{app_id = "discord";}
{class = "teams-for-linux";}
];
"4" = [{class = "Nxplayer.bin";}];
};
floating.criteria = [
{app_id = "foot";}
{app_id = "pavucontrol";}
{app_id = ".blueman-manager-wrapped";}
{app_id = "otpclient";}
{app_id = "thunar";}
{class = "Nxplayer.bin";}
];
startup = [{command = "dunst";}];
modifier = lib.mkDefault "Mod1";
terminal = lib.mkDefault "${pkgs.wezterm}/bin/wezterm";
window.titlebar = false;
workspaceAutoBackAndForth = true;
keybindings = lib.mkOptionDefault {
"${modifier}+Return" = "exec ${term}";
"${modifier}+Shift+Return" = "exec ${pkgs.foot}/bin/foot";
"${modifier}+q" = "kill";
"${modifier}+e" = "exec power-profiles";
"${modifier}+p" = "exec powermenu";
"${modifier}+v" = "floating toggle";
"${modifier}+space" = "exec ${pkgs.rofi}/bin/rofi -show drun";
"${modifier}+F1" = "exec ${pkgs.swaylock}/bin/swaylock";
"${modifier}+w" = "exec ${pkgs.firefox}/bin/firefox";
"${modifier}+f" = "exec ${pkgs.xfce.thunar}/bin/thunar";
"${modifier}+m" = "fullscreen toggle";
"${modifier}+c" = "scratchpad show";
"${modifier}+Shift+c" = "move scratchpad";
};
}; };
}; };
} }

View file

@ -26,10 +26,10 @@
enable_scroll_bar = false, enable_scroll_bar = false,
enable_wayland = true, enable_wayland = true,
window_padding = { window_padding = {
left = 2, left = 10,
right = 2, right = 10,
top = 2, top = 10,
bottom = 2, bottom = 10,
}, },
} }
''; '';

View file

@ -4,7 +4,7 @@
../../hardware/audio.nix ../../hardware/audio.nix
../../hardware/bluetooth.nix ../../hardware/bluetooth.nix
../../locales/en_GB.nix ../../locales/en_GB.nix
../../desktop/hyprland.nix ../../wm/sway.nix
../../services/syncthing/N0245.nix ../../services/syncthing/N0245.nix
]; ];

View file

@ -17,16 +17,29 @@
programs.firefox.package = pkgs.firefox-wayland; programs.firefox.package = pkgs.firefox-wayland;
wayland.windowManager.sway.config = { wayland.windowManager.sway.config = {
output = { output = {"Dell Inc. DELL U2417H 5K9YD872FY1L".transform = "270";};
# eDP-1 = {}; startup = [
# "Iiyama North America PLB2403WS 0574281251316" = {}; {command = "firefox";}
"Dell Inc. DELL U2417H 5K9YD872FY1L".transform = "270"; {command = "teams-for-linux";}
}; {command = "nxplayer.bin";}
];
workspaceOutputAssign = [ workspaceOutputAssign = [
{output="Iiyama North America PLB2403WS 0574281251316"; workspace="1";} {
{output="Iiyama North America PLB2403WS 0574281251316"; workspace="2";} output = "Iiyama North America PLB2403WS 0574281251316";
{output="Iiyama North America PLB2403WS 0574281251316"; workspace="3";} workspace = "1";
{output="Iiyama North America PLB2403WS 0574281251316"; workspace="4";} }
{
output = "Iiyama North America PLB2403WS 0574281251316";
workspace = "2";
}
{
output = "Iiyama North America PLB2403WS 0574281251316";
workspace = "3";
}
{
output = "Iiyama North America PLB2403WS 0574281251316";
workspace = "4";
}
]; ];
}; };
programs.waybar.settings = { programs.waybar.settings = {

View file

@ -1,13 +1,7 @@
{pkgs, ...}: { {pkgs, ...}: {
nixpkgs.overlays = [
(self: super: {
waybar = super.waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
});
})
];
services.blueman.enable = true; services.blueman.enable = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
gsettings-desktop-schemas
pavucontrol pavucontrol
pamixer pamixer
pulseaudio pulseaudio
@ -15,13 +9,6 @@
slurp slurp
]; ];
security.pam.services.swaylock = {}; security.pam.services.swaylock = {};
programs.hyprland = {
enable = true;
xwayland = {
enable = true;
hidpi = true;
};
};
programs.thunar = { programs.thunar = {
enable = true; enable = true;
plugins = with pkgs.xfce; [ plugins = with pkgs.xfce; [

17
wm/hyprland.nix Normal file
View file

@ -0,0 +1,17 @@
{...}: {
imports = [./default.nix];
nixpkgs.overlays = [
(self: super: {
waybar = super.waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
});
})
];
programs.hyprland = {
enable = true;
xwayland = {
enable = true;
hidpi = true;
};
};
}

29
wm/sway.nix Normal file
View file

@ -0,0 +1,29 @@
{pkgs, ...}: let
# bash script to let dbus know about important env variables and
# propogate them to relevent services run at the end of sway config
# see
# https://github.com/emersion/xdg-desktop-portal-wlr/wiki/"It-doesn't-work"-Troubleshooting-Checklist
dbus-sway-environment = pkgs.writeTextFile {
name = "dbus-sway-environment";
destination = "/bin/dbus-sway-environment";
executable = true;
text = ''
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
'';
};
in {
imports = [./default.nix];
environment.systemPackages = [dbus-sway-environment];
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = [pkgs.xdg-desktop-portal-gtk];
};
programs.sway = {
enable = true;
package = null;
};
}