diff --git a/Makefile b/Makefile index f0079e12..0fda0ac8 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,13 @@ HOMEMANAGER_CONFIG := $(PWD)/machines/$(HOSTNAME)/$(USER).nix CONFIG_DIR := $(if $(XDG_CONFIG_HOME), $(XDG_CONFIG_HOME), $(HOME)/.config) 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 if [ -e /etc/nixos/ ]; then make nixos; else make home; fi + +all: default nvim bat cache --build clean: diff --git a/home/desktop/gtk.nix b/home/desktop/gtk.nix index 0281cd8b..724260c2 100644 --- a/home/desktop/gtk.nix +++ b/home/desktop/gtk.nix @@ -2,12 +2,13 @@ candy-icon-theme = pkgs.callPackage ./pkgs/candy-icon-theme {}; sweet-folder-theme = pkgs.callPackage ./pkgs/sweet-folder-theme {}; in { - home.packages = [ + home.packages = with pkgs; [ + glib candy-icon-theme sweet-folder-theme - pkgs.breeze-gtk - pkgs.gnome.adwaita-icon-theme - pkgs.hicolor-icon-theme + breeze-gtk + gnome.adwaita-icon-theme + hicolor-icon-theme ]; gtk = { enable = true; @@ -24,4 +25,5 @@ in { name = "Sweet-Dark"; }; }; + services.xsettingsd.enable = true; } diff --git a/home/desktop/rofi.nix b/home/desktop/rofi.nix index 7c03cc91..5aeb50bb 100644 --- a/home/desktop/rofi.nix +++ b/home/desktop/rofi.nix @@ -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); power-profiles = pkgs.writeShellScriptBin "power-profiles" (builtins.readFile ./scripts/power-profiles); + icon-theme = config.gtk.iconTheme.name; in { imports = [../gui/foot.nix ./gtk.nix]; - home.packages = [logout-utility powermenu power-profiles]; + home.packages = [powermenu power-profiles]; programs.rofi = { enable = true; location = "center"; pass.enable = true; terminal = "wezterm"; - plugins = with pkgs; [ - rofi-calc - ]; extraConfig = { modi = "drun"; - icon-theme = "Sweet-Rainbow"; + icon-theme = icon-theme; show-icons = true; drun-display-format = "{icon} {name}"; disable-history = false; hide-scrollbar = true; - # display-drun = "  Apps "; display-run = "  Run "; - # display-window = " 﩯 Window"; - # display-calc = " √ Calculator"; - # sidebar-mode = true; }; theme = ./config/rofi/catppuccin-macchiato.rasi; }; diff --git a/home/desktop/scripts/logout-utility b/home/desktop/scripts/logout-utility deleted file mode 100644 index 372443b1..00000000 --- a/home/desktop/scripts/logout-utility +++ /dev/null @@ -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 diff --git a/home/desktop/scripts/power-profiles b/home/desktop/scripts/power-profiles old mode 100755 new mode 100644 diff --git a/home/desktop/scripts/powermenu b/home/desktop/scripts/powermenu old mode 100755 new mode 100644 index 4543e604..55787104 --- a/home/desktop/scripts/powermenu +++ b/home/desktop/scripts/powermenu @@ -117,8 +117,8 @@ menu=( [ Reboot]="systemctl reboot" [ Suspend]="systemctl suspend" [ Hibernate]="systemctl hibernate" - [ Lock]="hyprctl dispatch exec swaylock" - [ Logout]="logout-utility" + [ Lock]="swaymsg exec swaylock" + [ Logout]="swaymsg exit" [ Cancel]="" ) diff --git a/home/desktop/sway.nix b/home/desktop/sway.nix index 88c31b25..f235a3ce 100644 --- a/home/desktop/sway.nix +++ b/home/desktop/sway.nix @@ -6,6 +6,30 @@ }: let modifier = config.wayland.windowManager.sway.config.modifier; 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 { imports = [ ./swaylock.nix @@ -13,8 +37,11 @@ in { ./gtk.nix ./dunst.nix ./rofi.nix + ../gui/foot.nix ]; home.packages = with pkgs; [ + configure-gtk + swaycons pipewire wireplumber wl-clipboard @@ -24,6 +51,13 @@ in { programs.rofi.package = pkgs.rofi-wayland; wayland.windowManager.sway = { 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 = { input."*".xkb_layout = "gb"; output."*".bg = "~/nixos/wallpaper.jpg fill"; @@ -36,6 +70,59 @@ in { outer = lib.mkDefault 20; }; 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 = { focused = { border = "#4c7899"; @@ -74,45 +161,6 @@ in { }; 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"; - }; }; }; } diff --git a/home/gui/wezterm.nix b/home/gui/wezterm.nix index 08a31e14..e61a5bc9 100644 --- a/home/gui/wezterm.nix +++ b/home/gui/wezterm.nix @@ -26,10 +26,10 @@ enable_scroll_bar = false, enable_wayland = true, window_padding = { - left = 2, - right = 2, - top = 2, - bottom = 2, + left = 10, + right = 10, + top = 10, + bottom = 10, }, } ''; diff --git a/machines/N0245/default.nix b/machines/N0245/default.nix index 2c26e780..8518abf1 100644 --- a/machines/N0245/default.nix +++ b/machines/N0245/default.nix @@ -4,7 +4,7 @@ ../../hardware/audio.nix ../../hardware/bluetooth.nix ../../locales/en_GB.nix - ../../desktop/hyprland.nix + ../../wm/sway.nix ../../services/syncthing/N0245.nix ]; diff --git a/machines/N0245/elitherl.nix b/machines/N0245/elitherl.nix index f5a38671..baededc7 100644 --- a/machines/N0245/elitherl.nix +++ b/machines/N0245/elitherl.nix @@ -17,16 +17,29 @@ programs.firefox.package = pkgs.firefox-wayland; wayland.windowManager.sway.config = { - output = { - # eDP-1 = {}; - # "Iiyama North America PLB2403WS 0574281251316" = {}; - "Dell Inc. DELL U2417H 5K9YD872FY1L".transform = "270"; - }; + output = {"Dell Inc. DELL U2417H 5K9YD872FY1L".transform = "270";}; + startup = [ + {command = "firefox";} + {command = "teams-for-linux";} + {command = "nxplayer.bin";} + ]; workspaceOutputAssign = [ - {output="Iiyama North America PLB2403WS 0574281251316"; workspace="1";} - {output="Iiyama North America PLB2403WS 0574281251316"; workspace="2";} - {output="Iiyama North America PLB2403WS 0574281251316"; workspace="3";} - {output="Iiyama North America PLB2403WS 0574281251316"; workspace="4";} + { + output = "Iiyama North America PLB2403WS 0574281251316"; + workspace = "1"; + } + { + 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 = { diff --git a/desktop/hyprland.nix b/wm/default.nix similarity index 60% rename from desktop/hyprland.nix rename to wm/default.nix index 03508969..e0fefa3f 100644 --- a/desktop/hyprland.nix +++ b/wm/default.nix @@ -1,13 +1,7 @@ {pkgs, ...}: { - nixpkgs.overlays = [ - (self: super: { - waybar = super.waybar.overrideAttrs (oldAttrs: { - mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"]; - }); - }) - ]; services.blueman.enable = true; environment.systemPackages = with pkgs; [ + gsettings-desktop-schemas pavucontrol pamixer pulseaudio @@ -15,13 +9,6 @@ slurp ]; security.pam.services.swaylock = {}; - programs.hyprland = { - enable = true; - xwayland = { - enable = true; - hidpi = true; - }; - }; programs.thunar = { enable = true; plugins = with pkgs.xfce; [ diff --git a/wm/hyprland.nix b/wm/hyprland.nix new file mode 100644 index 00000000..f4dc4d6a --- /dev/null +++ b/wm/hyprland.nix @@ -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; + }; + }; +} diff --git a/wm/sway.nix b/wm/sway.nix new file mode 100644 index 00000000..59a9a752 --- /dev/null +++ b/wm/sway.nix @@ -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; + }; +}