From 2b6e087f38e3895157758184a1c93bde14f18c9c Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 12 Jan 2025 18:44:43 -0300 Subject: [PATCH 01/27] feat: start adding sway config --- home/linux/gui/sway/default.nix | 42 +++++++++++++++++++++++++ home/linux/gui/sway/values/default.nix | 4 +++ home/linux/gui/sway/values/packages.nix | 5 +++ home/linux/gui/sway/values/sway.nix | 13 ++++++++ 4 files changed, 64 insertions(+) create mode 100644 home/linux/gui/sway/default.nix create mode 100644 home/linux/gui/sway/values/default.nix create mode 100644 home/linux/gui/sway/values/packages.nix create mode 100644 home/linux/gui/sway/values/sway.nix diff --git a/home/linux/gui/sway/default.nix b/home/linux/gui/sway/default.nix new file mode 100644 index 00000000..37b6cf97 --- /dev/null +++ b/home/linux/gui/sway/default.nix @@ -0,0 +1,42 @@ +{ + pkgs, + config, + lib, + anyrun, + ... +} @ args: +with lib; let + cfg = config.modules.desktop.sway; +in { + options.modules.desktop.sway = { + enable = mkEnableOption "sway wm"; + settings = lib.mkOption { + type = with lib.types; let + valueType = + nullOr (oneOf [ + bool + int + float + str + path + (attrsOf valueType) + (listOf valueType) + ]) + // { + description = "sway configuration value"; + }; + in + valueType; + default = {}; + }; + }; + + config = mkIf cfg.enable ( + mkMerge ([ + { + wayland.windowManager.sway.config = cfg.settings; + } + ] + ++ (import ./values args)) + ); +} diff --git a/home/linux/gui/sway/values/default.nix b/home/linux/gui/sway/values/default.nix new file mode 100644 index 00000000..7fcf4261 --- /dev/null +++ b/home/linux/gui/sway/values/default.nix @@ -0,0 +1,4 @@ +{mylib, ...} @ args: +map +(path: import path args) +(mylib.file.scanPaths ./.) diff --git a/home/linux/gui/sway/values/packages.nix b/home/linux/gui/sway/values/packages.nix new file mode 100644 index 00000000..6b8e58ea --- /dev/null +++ b/home/linux/gui/sway/values/packages.nix @@ -0,0 +1,5 @@ +{pkgs, ...}: { + home.packages = with pkgs; [ + dunst + ]; +} diff --git a/home/linux/gui/sway/values/sway.nix b/home/linux/gui/sway/values/sway.nix new file mode 100644 index 00000000..efe1c85e --- /dev/null +++ b/home/linux/gui/sway/values/sway.nix @@ -0,0 +1,13 @@ +{ + lib, + pkgs, + ... +}: +with lib; let + pkg = pkgs.sway; +in { + wayland.windowManager.sway = { + enable = true; + package = pkg; + }; +} From f8bc7574a98b3fb8855c58e2025dd11aa64b34fc Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Wed, 15 Jan 2025 11:43:27 -0300 Subject: [PATCH 02/27] feat: add sway configurations and replacements Currently was able to start it, but chromium had no dark mode as if the cmd line flags were ignored, and it also had a lot of flickering, flashing issues. Later on though, sway is not starting at all anymore, with "failed to start rendered" message. --- home/linux/gui/base/gtk.nix | 5 ++ home/linux/gui/sway/values/sway.nix | 4 +- hosts/dtsf-pc/home/default.nix | 11 ++-- hosts/dtsf-pc/home/keymaps.nix | 6 +- modules/colorscheme/home.nix | 13 ++++ modules/colorscheme/integrations/sway.nix | 72 +++++++++++++++++++++++ modules/nixos/desktop.nix | 1 + modules/wallpaper/nixos.nix | 39 ++++++++++-- outputs/x86_64-linux/src/dtsf-pc.nix | 11 ++-- 9 files changed, 139 insertions(+), 23 deletions(-) create mode 100644 modules/colorscheme/integrations/sway.nix diff --git a/home/linux/gui/base/gtk.nix b/home/linux/gui/base/gtk.nix index 00bf5146..85510036 100644 --- a/home/linux/gui/base/gtk.nix +++ b/home/linux/gui/base/gtk.nix @@ -27,4 +27,9 @@ gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; }; + + xdg.configFile."gtk-3.0/settings.ini".text = '' + [Settings] + gtk-application-prefer-dark-theme=1 + ''; } diff --git a/home/linux/gui/sway/values/sway.nix b/home/linux/gui/sway/values/sway.nix index efe1c85e..eb39ab60 100644 --- a/home/linux/gui/sway/values/sway.nix +++ b/home/linux/gui/sway/values/sway.nix @@ -1,10 +1,10 @@ { lib, - pkgs, + pkgs-unstable, ... }: with lib; let - pkg = pkgs.sway; + pkg = pkgs-unstable.sway; in { wayland.windowManager.sway = { enable = true; diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index e74e4692..18dca029 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -8,14 +8,13 @@ modules.desktop.colorscheme.theme = "gruvbox"; modules.desktop = { - i3 = let + sway = let mod = "Mod4"; alt = "Mod1"; keymaps = import ./keymaps.nix {inherit mod alt pkgs lib;}; command = str: always: { command = str; always = always; - notification = false; }; in { settings = { @@ -24,11 +23,11 @@ keybindings = keymaps.allBindings; startup = [ - (command "dex --autostart --environment i3" true) - (command "xss-lock --transfer-sleep-lock -- i3lock-theme" true) - (command "autorandr --load desktop" true) + # (command "dex --autostart --environment i3" true) + # (command "xss-lock --transfer-sleep-lock -- i3lock-theme" true) + # (command "autorandr --load desktop" true) (command "udiskie --tray --notify" false) - (command "i3-msg 'workspace 1'" false) + (command "swaymsg 'workspace 1'" false) (command "dunst -config $HOME/.config/dunstrc" false) ]; diff --git a/hosts/dtsf-pc/home/keymaps.nix b/hosts/dtsf-pc/home/keymaps.nix index 9279c763..d8e5e02c 100644 --- a/hosts/dtsf-pc/home/keymaps.nix +++ b/hosts/dtsf-pc/home/keymaps.nix @@ -64,9 +64,9 @@ "${mod}+r" = "mode resize"; "${mod}+Shift+c" = "reload"; - "${mod}+Shift+r" = "exec i3-msg restart"; - "${mod}+Shift+e" = "exec \"i3-nagbar -t warning -m 'leave i3' -B 'exit i3' 'exec i3-msg exit; pkill -15 Xorg'\""; - "${mod}+Shift+o" = "exec \"i3-nagbar -t error -m 'turn off the computer' -B 'turn off' 'systemctl poweroff'\""; + "${mod}+Shift+r" = "exec swaymsg restart"; + "${mod}+Shift+e" = "exec \"swaynag -t warning -m 'leave sway' -B 'exit sway' 'exec swaymsg exit'\""; + "${mod}+Shift+o" = "exec \"swaynag -t error -m 'turn off the computer' -B 'turn off' 'systemctl poweroff'\""; "XF86MonBrightnessUp" = "exec --no-startup-id brightnessctl set +5%"; "XF86MonBrightnessDown" = "exec --no-startup-id brightnessctl set 5%-"; diff --git a/modules/colorscheme/home.nix b/modules/colorscheme/home.nix index d1d7a3a3..ffb4f5fa 100644 --- a/modules/colorscheme/home.nix +++ b/modules/colorscheme/home.nix @@ -58,6 +58,10 @@ to the user ".local/bin" folder, which should be used instead of i3lock. ''; }; + enableSwayIntegration = lib.mkOption { + type = lib.types.bool; + default = false; + }; enableFishIntegration = lib.mkOption { type = lib.types.bool; default = false; @@ -104,6 +108,15 @@ }) ) + ( + lib.mkIf config.modules.desktop.colorscheme.enableSwayIntegration + (import ./integrations/sway.nix { + inherit lib pkgs; + colorscheme = colorscheme; + enableI3StatusIntegration = config.modules.desktop.colorscheme.enableI3StatusIntegration; + }) + ) + ( lib.mkIf config.modules.desktop.colorscheme.enableDunstIntegration (import ./integrations/dunst.nix { diff --git a/modules/colorscheme/integrations/sway.nix b/modules/colorscheme/integrations/sway.nix new file mode 100644 index 00000000..1dc8bc75 --- /dev/null +++ b/modules/colorscheme/integrations/sway.nix @@ -0,0 +1,72 @@ +{ + lib, + colorscheme, + pkgs, + enableI3StatusIntegration, + ... +}: { + wayland.windowManager.sway.config = { + colors = { + background = colorscheme.colors.bg; + focused = { + background = colorscheme.colors.altbg; + border = colorscheme.colors.altbg; + childBorder = colorscheme.colors.altbg; + indicator = colorscheme.colors.altbg; + text = colorscheme.colors.fg; + }; + focusedInactive = { + background = colorscheme.colors.altbg; + border = colorscheme.colors.bg; + childBorder = colorscheme.colors.altbg; + indicator = colorscheme.colors.altbg; + text = colorscheme.colors.fg; + }; + unfocused = { + background = colorscheme.colors.bg; + border = colorscheme.colors.bg; + childBorder = colorscheme.colors.bg; + indicator = colorscheme.colors.bg; + text = colorscheme.colors.fg; + }; + urgent = { + background = colorscheme.colors.red; + border = colorscheme.colors.red; + childBorder = colorscheme.colors.red; + indicator = colorscheme.colors.red; + text = colorscheme.colors.fg; + }; + }; + bars = [ + { + id = "bar-0"; + statusCommand = lib.mkIf enableI3StatusIntegration "i3status"; + colors = { + focusedWorkspace = { + background = "${colorscheme.colors.altbg}"; + border = "${colorscheme.colors.altbg}cc"; + text = "${colorscheme.colors.fg}"; + }; + }; + } + ]; + }; + + programs.i3status = lib.mkIf enableI3StatusIntegration { + general = { + color_good = colorscheme.colors.green; + color_degraded = colorscheme.colors.yellow; + color_bad = colorscheme.colors.red; + color_separator = colorscheme.colors.bg; + }; + }; + + home.file.".local/bin/dmenu-theme".text = '' + #!/usr/bin/env bash + ${pkgs.dmenu}/bin/dmenu_run -nb "${colorscheme.colors.bg}" \ + -nf "${colorscheme.colors.fg}" \ + -sb "${colorscheme.colors.altbg}" \ + -sf "${colorscheme.colors.fg}" + ''; + home.file.".local/bin/dmenu-theme".executable = true; +} diff --git a/modules/nixos/desktop.nix b/modules/nixos/desktop.nix index 4019c3d7..bba754a4 100644 --- a/modules/nixos/desktop.nix +++ b/modules/nixos/desktop.nix @@ -34,6 +34,7 @@ in { xdg-desktop-portal-wlr ]; }; + environment.sessionVariables.NIXOS_OZONE_WL = "1"; services = { xserver.enable = false; diff --git a/modules/wallpaper/nixos.nix b/modules/wallpaper/nixos.nix index 78c3d76a..925fd6f9 100644 --- a/modules/wallpaper/nixos.nix +++ b/modules/wallpaper/nixos.nix @@ -13,11 +13,16 @@ with lib; { config = mkIf ( config.modules.desktop.wallpaper.enable - && config.services.xserver.enable ) { systemd.user.services.link-wallpaper = { description = "Create wallpaper symlink"; - after = ["graphical-session.target"]; + after = [ + ( + if config.modules.desktop.wayland.enable + then "sway-session.target" + else "graphical-session.target" + ) + ]; wantedBy = ["default.target"]; path = [pkgs.coreutils]; script = '' @@ -41,18 +46,40 @@ with lib; { systemd.user.services.wallpaper = { description = "Set wallpaper"; - after = ["link-wallpaper.service" "graphical-session.target"]; + after = [ + "link-wallpaper.service" + ( + if config.modules.desktop.wayland.enable + then "sway-session.target" + else "graphical-session.target" + ) + ]; wantedBy = ["default.target"]; - path = [pkgs.feh]; + path = + if config.modules.desktop.wayland.enable + then [] + else [pkgs.feh]; script = '' - ${pkgs.feh}/bin/feh --bg-fill /home/${myvars.username}/.local/share/wallpaper/current + ${ + if config.modules.desktop.wayland.enable + then '' + swaymsg output "*" bg /home/${myvars.username}/.local/share/wallpaper/current fill + '' + else '' + ${pkgs.feh}/bin/feh --bg-fill /home/${myvars.username}/.local/share/wallpaper/current + '' + } ''; serviceConfig = { Type = "oneshot"; RemainAfterExit = true; Environment = [ "HOME=/home/${myvars.username}" - "DISPLAY=:0" + ( + if config.modules.desktop.xorg.enable + then "DISPLAY=:0" + else "" + ) ]; Restart = "on-failure"; RestartSec = 5; diff --git a/outputs/x86_64-linux/src/dtsf-pc.nix b/outputs/x86_64-linux/src/dtsf-pc.nix index 0c6c112c..9632889d 100644 --- a/outputs/x86_64-linux/src/dtsf-pc.nix +++ b/outputs/x86_64-linux/src/dtsf-pc.nix @@ -32,11 +32,11 @@ ]; }; - modules-i3 = { + modules-sway = { nixos-modules = [ { - modules.desktop.xorg.enable = true; + modules.desktop.wayland.enable = true; modules.desktop.wallpaper.enable = true; modules.desktop.nvidia.enable = true; modules.ssh-key-manager.enable = true; @@ -46,7 +46,7 @@ home-modules = [ { - modules.desktop.i3.enable = true; + modules.desktop.sway.enable = true; modules.desktop.nupkgs.enable = true; modules.desktop.conf = { enableDunstIntegration = true; @@ -58,8 +58,7 @@ enable = true; enableNeovimIntegration = true; enableGTKIntegration = true; - enableI3Integration = true; - enableI3LockIntegration = true; + enableSwayIntegration = true; enableI3StatusIntegration = true; enableDunstIntegration = true; enableAlacrittyIntegration = true; @@ -74,6 +73,6 @@ }; in { nixosConfigurations = { - "${name}" = mylib.nixosSystem (modules-i3 // args); + "${name}" = mylib.nixosSystem (modules-sway // args); }; } From 2d3ce9e30d52e4535ad4475db8eddae34768349f Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Wed, 15 Jan 2025 11:49:18 -0300 Subject: [PATCH 03/27] docs: add caution note about current broken state of this config --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 388005a4..543ebf67 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +> [!CAUTION] +> If you are using an NVIDIA GPU, it's worth knowing that my attempts to make it work with mine have been unsuccessful. +> So this configuration might not work for you as well. If you don't have an NVIDIA GPU, then you might try, but I can't confirm it will work either. +
# datsfilipe’s dotfiles From 5e74ac9fe7193d13e3d44afe2477a6f0bc2ac1bd Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 00:04:22 -0300 Subject: [PATCH 04/27] chore: add packages for wayland sway --- home/linux/gui/sway/values/packages.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/home/linux/gui/sway/values/packages.nix b/home/linux/gui/sway/values/packages.nix index 6b8e58ea..689ee344 100644 --- a/home/linux/gui/sway/values/packages.nix +++ b/home/linux/gui/sway/values/packages.nix @@ -1,5 +1,8 @@ {pkgs, ...}: { home.packages = with pkgs; [ dunst + wl-clipboard + libappindicator-gtk3 + networkmanagerapplet ]; } From 79028178aff03475de24b2842da9c1fc418ea250 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 00:05:26 -0300 Subject: [PATCH 05/27] feat: update keymaps for sway --- hosts/dtsf-pc/home/keymaps.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hosts/dtsf-pc/home/keymaps.nix b/hosts/dtsf-pc/home/keymaps.nix index d8e5e02c..ea340114 100644 --- a/hosts/dtsf-pc/home/keymaps.nix +++ b/hosts/dtsf-pc/home/keymaps.nix @@ -8,6 +8,11 @@ mod = "Mod4"; alt = "Mod1"; print = "Print"; + + exit = "-B 'leave' 'exec swaymsg exit && exec loginctl terminate-user $USER'"; + turnoff = "-B 'shutdown' 'exec systemctl poweroff'"; + reboot = "-B 'reboot' 'exec systemctl reboot'"; + workspaceBindings = builtins.listToAttrs ( (map (i: { name = "${mod}+${toString i}"; @@ -32,7 +37,7 @@ "${mod}+q" = "kill"; "${mod}+t" = "exec ${pkgs.alacritty}/bin/alacritty"; "${mod}+Return" = "exec ${pkgs.alacritty}/bin/alacritty -e ${pkgs.zellij}/bin/zellij attach dtsf -c"; - "${mod}+a" = "exec chromium --wv --force-dark-mode --enable-features=WebUIDarkMode"; + "${mod}+a" = "exec chromium --wv --force-dark-mode --enable-features=WebUIDarkMode --disable-gpu"; "${mod}+d" = "exec $HOME/.local/bin/dmenu-theme"; "${mod}+Shift+m" = "exec shimeji"; @@ -64,9 +69,7 @@ "${mod}+r" = "mode resize"; "${mod}+Shift+c" = "reload"; - "${mod}+Shift+r" = "exec swaymsg restart"; - "${mod}+Shift+e" = "exec \"swaynag -t warning -m 'leave sway' -B 'exit sway' 'exec swaymsg exit'\""; - "${mod}+Shift+o" = "exec \"swaynag -t error -m 'turn off the computer' -B 'turn off' 'systemctl poweroff'\""; + "${mod}+Shift+e" = "exec \"swaynag -t warning -m 'leave, shutdown or reboot?' ${turnoff} ${reboot} ${exit}\""; "XF86MonBrightnessUp" = "exec --no-startup-id brightnessctl set +5%"; "XF86MonBrightnessDown" = "exec --no-startup-id brightnessctl set 5%-"; From 4581b567250d1420dae46f3b0da74d3357bb03de Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 00:12:19 -0300 Subject: [PATCH 06/27] feat: add extra options for sway tray still doesn't work --- hosts/dtsf-pc/home/default.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index 18dca029..36e36f33 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -23,10 +23,7 @@ keybindings = keymaps.allBindings; startup = [ - # (command "dex --autostart --environment i3" true) - # (command "xss-lock --transfer-sleep-lock -- i3lock-theme" true) - # (command "autorandr --load desktop" true) - (command "udiskie --tray --notify" false) + (command "udiskie --appindicator --tray --notify" false) (command "swaymsg 'workspace 1'" false) (command "dunst -config $HOME/.config/dunstrc" false) ]; @@ -62,6 +59,13 @@ criteria = {title = "^win";}; } ]; + + input = { + "1133:16500:Logitech_G305" = { + accel_profile = "flat"; + pointer_accel = "0"; + }; + }; }; }; }; From abfac3359ca390a253476cb338d3fd4cae0a6958 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 00:14:45 -0300 Subject: [PATCH 07/27] feat: add options for wayland to nvidia config --- modules/nixos/desktop/nvidia.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/nixos/desktop/nvidia.nix b/modules/nixos/desktop/nvidia.nix index 04c2490a..32c3b338 100644 --- a/modules/nixos/desktop/nvidia.nix +++ b/modules/nixos/desktop/nvidia.nix @@ -9,7 +9,15 @@ with lib; { }; config = mkIf config.modules.desktop.nvidia.enable { + environment.variables = mkIf config.modules.desktop.wayland.enable { + LIBVA_DRIVER_NAME = "nvidia"; + NVD_BACKEND = "direct"; + NIXOS_OZONE_WL = "1"; + ELECTRON_OZONE_PLATFORM_HINT = "auto"; + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + }; boot.extraModprobeConfig = "options nvidia-drm modeset=1"; + boot.kernelParams = ["nvidia.NVreg_EnableGpuFirmware=0" "nvidia.NVreg_PreserveVideoMemoryAllocations=1"]; boot.initrd.kernelModules = config.boot.kernelModules ++ [ @@ -23,7 +31,7 @@ with lib; { package = config.boot.kernelPackages.nvidiaPackages.latest; modesetting.enable = true; powerManagement.enable = true; - forceFullCompositionPipeline = true; + forceFullCompositionPipeline = false; nvidiaSettings = true; open = false; }; From 8bf67be89011486ad533905bdff69bd1ef596d11 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 00:15:36 -0300 Subject: [PATCH 08/27] feat: add sway startup and start wallpaper service there not able to make wallpaper service restart on session logout as with xserver --- modules/nixos/desktop.nix | 18 +++++++++++++++++- modules/wallpaper/nixos.nix | 12 +++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/nixos/desktop.nix b/modules/nixos/desktop.nix index bba754a4..0f42b51f 100644 --- a/modules/nixos/desktop.nix +++ b/modules/nixos/desktop.nix @@ -39,6 +39,22 @@ in { services = { xserver.enable = false; }; + + programs.sway.wrapperFeatures.gtk = true; + + environment = { + pathsToLink = ["/libexec"]; + loginShellInit = '' + if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then + ${( + if config.modules.desktop.wallpaper.enable + then "systemctl --user restart wallpaper.service &" + else "" + )} + exec sway --unsupported-gpu + fi + ''; + }; }) (mkIf cfgXorg.enable { @@ -80,7 +96,7 @@ in { loginShellInit = '' if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then exec startx - fi + fi ''; }; }) diff --git a/modules/wallpaper/nixos.nix b/modules/wallpaper/nixos.nix index 925fd6f9..b6950d4f 100644 --- a/modules/wallpaper/nixos.nix +++ b/modules/wallpaper/nixos.nix @@ -20,8 +20,9 @@ with lib; { ( if config.modules.desktop.wayland.enable then "sway-session.target" - else "graphical-session.target" + else "" ) + "graphical-session.target" ]; wantedBy = ["default.target"]; path = [pkgs.coreutils]; @@ -51,19 +52,20 @@ with lib; { ( if config.modules.desktop.wayland.enable then "sway-session.target" - else "graphical-session.target" + else "" ) + "graphical-session.target" ]; wantedBy = ["default.target"]; path = if config.modules.desktop.wayland.enable - then [] + then [pkgs.sway] else [pkgs.feh]; script = '' ${ if config.modules.desktop.wayland.enable then '' - swaymsg output "*" bg /home/${myvars.username}/.local/share/wallpaper/current fill + ${pkgs.sway}/bin/swaymsg output "*" bg /home/${myvars.username}/.local/share/wallpaper/current fill '' else '' ${pkgs.feh}/bin/feh --bg-fill /home/${myvars.username}/.local/share/wallpaper/current @@ -78,7 +80,7 @@ with lib; { ( if config.modules.desktop.xorg.enable then "DISPLAY=:0" - else "" + else "WAYLAND_DISPLAY=wayland-1" ) ]; Restart = "on-failure"; From 5872e58af0af3d39583d36c5a7bbadc9a845e092 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 00:16:19 -0300 Subject: [PATCH 09/27] fix: not starting xdg portal because it messes up with my dark mode chromium even ignores the flags, not sure what I'm doing wrong --- modules/nixos/desktop/graphics.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/nixos/desktop/graphics.nix b/modules/nixos/desktop/graphics.nix index b5734a84..382c5c5a 100644 --- a/modules/nixos/desktop/graphics.nix +++ b/modules/nixos/desktop/graphics.nix @@ -10,9 +10,9 @@ }; }; - xdgOpenUsePortal = false; - extraPortals = with pkgs; [ - xdg-desktop-portal-gtk - ]; + # xdgOpenUsePortal = false; + # extraPortals = with pkgs; [ + # xdg-desktop-portal-gtk + # ]; }; } From 5f16926090de63b3aa969cd0128305e346d61dd2 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 00:20:30 -0300 Subject: [PATCH 10/27] refactor: restart wallpaper service on sway startup --- hosts/dtsf-pc/home/default.nix | 5 +++-- modules/nixos/desktop.nix | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index 36e36f33..3d6c83df 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -23,9 +23,10 @@ keybindings = keymaps.allBindings; startup = [ - (command "udiskie --appindicator --tray --notify" false) + (command "udiskie --appindicator --tray --notify" true) (command "swaymsg 'workspace 1'" false) - (command "dunst -config $HOME/.config/dunstrc" false) + (command "dunst -config $HOME/.config/dunstrc" true) + (command "systemctl --user restart wallpaper.service" true) ]; modes = { diff --git a/modules/nixos/desktop.nix b/modules/nixos/desktop.nix index 0f42b51f..91b8d642 100644 --- a/modules/nixos/desktop.nix +++ b/modules/nixos/desktop.nix @@ -46,11 +46,6 @@ in { pathsToLink = ["/libexec"]; loginShellInit = '' if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then - ${( - if config.modules.desktop.wallpaper.enable - then "systemctl --user restart wallpaper.service &" - else "" - )} exec sway --unsupported-gpu fi ''; From 972de82f87b8651a3643d43bf2bee47ab6f8b091 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 00:27:45 -0300 Subject: [PATCH 11/27] refactor: remove udiskie tray since not working --- hosts/dtsf-pc/home/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index 3d6c83df..1d54eb9c 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -23,7 +23,7 @@ keybindings = keymaps.allBindings; startup = [ - (command "udiskie --appindicator --tray --notify" true) + (command "udiskie --notify" true) (command "swaymsg 'workspace 1'" false) (command "dunst -config $HOME/.config/dunstrc" true) (command "systemctl --user restart wallpaper.service" true) From c7b9a61ae5be585c816ebdecbc77d4ae48b1dff3 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 13:51:22 -0300 Subject: [PATCH 12/27] refactor: use bemenu on sway --- home/linux/gui/sway/values/packages.nix | 1 + hosts/dtsf-pc/home/keymaps.nix | 2 +- modules/colorscheme/integrations/sway.nix | 20 ++++++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/home/linux/gui/sway/values/packages.nix b/home/linux/gui/sway/values/packages.nix index 689ee344..bbd86680 100644 --- a/home/linux/gui/sway/values/packages.nix +++ b/home/linux/gui/sway/values/packages.nix @@ -4,5 +4,6 @@ wl-clipboard libappindicator-gtk3 networkmanagerapplet + bemenu ]; } diff --git a/hosts/dtsf-pc/home/keymaps.nix b/hosts/dtsf-pc/home/keymaps.nix index ea340114..2516b390 100644 --- a/hosts/dtsf-pc/home/keymaps.nix +++ b/hosts/dtsf-pc/home/keymaps.nix @@ -38,7 +38,7 @@ "${mod}+t" = "exec ${pkgs.alacritty}/bin/alacritty"; "${mod}+Return" = "exec ${pkgs.alacritty}/bin/alacritty -e ${pkgs.zellij}/bin/zellij attach dtsf -c"; "${mod}+a" = "exec chromium --wv --force-dark-mode --enable-features=WebUIDarkMode --disable-gpu"; - "${mod}+d" = "exec $HOME/.local/bin/dmenu-theme"; + "${mod}+d" = "exec $HOME/.local/bin/launcher"; "${mod}+Shift+m" = "exec shimeji"; "${alt}+k" = "exec $HOME/.local/bin/switch-kb-variant"; diff --git a/modules/colorscheme/integrations/sway.nix b/modules/colorscheme/integrations/sway.nix index 1dc8bc75..2d6eb6f9 100644 --- a/modules/colorscheme/integrations/sway.nix +++ b/modules/colorscheme/integrations/sway.nix @@ -61,12 +61,20 @@ }; }; - home.file.".local/bin/dmenu-theme".text = '' + home.file.".local/bin/launcher".text = '' #!/usr/bin/env bash - ${pkgs.dmenu}/bin/dmenu_run -nb "${colorscheme.colors.bg}" \ - -nf "${colorscheme.colors.fg}" \ - -sb "${colorscheme.colors.altbg}" \ - -sf "${colorscheme.colors.fg}" + ${pkgs.bemenu}/bin/bemenu-run -H 25 -p "" \ + --tb "${colorscheme.colors.altbg}" \ + --fb "${colorscheme.colors.altbg}" \ + --fbb "${colorscheme.colors.altbg}" \ + --nb "${colorscheme.colors.altbg}" \ + --nf "${colorscheme.colors.fg}" \ + --af "${colorscheme.colors.fg}" \ + --ab "${colorscheme.colors.altbg}" \ + --sb "${colorscheme.colors.altbg}" \ + --sf "${colorscheme.colors.fg}" \ + --hb "${colorscheme.colors.altbg}" \ + --hf "${colorscheme.colors.primary}" ''; - home.file.".local/bin/dmenu-theme".executable = true; + home.file.".local/bin/launcher".executable = true; } From 1da62319a41031939cf44f438af32897d3257d8d Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 15:27:34 -0300 Subject: [PATCH 13/27] feat: remove window titles in sway --- hosts/dtsf-pc/home/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index 1d54eb9c..bcf3f431 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -59,6 +59,10 @@ command = "floating enable, sticky enable"; criteria = {title = "^win";}; } + { + command = "title_format \" \""; + criteria = {title = "^.*$";}; + } ]; input = { From 5ec3cfd4c6c7f7babfe42b92c27db6e742de01a5 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 16:11:29 -0300 Subject: [PATCH 14/27] feat: export var for java applications --- home/linux/gui/sway/values/sway.nix | 3 +++ hosts/dtsf-pc/home/default.nix | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/home/linux/gui/sway/values/sway.nix b/home/linux/gui/sway/values/sway.nix index eb39ab60..e92c1792 100644 --- a/home/linux/gui/sway/values/sway.nix +++ b/home/linux/gui/sway/values/sway.nix @@ -9,5 +9,8 @@ in { wayland.windowManager.sway = { enable = true; package = pkg; + extraSessionCommands = '' + export _JAVA_AWT_WM_NONREPARENTING=1 + ''; }; } diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index bcf3f431..968f42c4 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -47,13 +47,13 @@ }; }; - window.titlebar = true; fonts = { names = ["JetBrainsMono Nerd Font"]; style = "Regular"; size = 8.0; }; + window.titlebar = true; window.commands = [ { command = "floating enable, sticky enable"; From eeeccc5fb5edf28cc78534f392f138f036e6fab0 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 16:31:26 -0300 Subject: [PATCH 15/27] refactor: use default wmenu --- home/linux/gui/sway/values/packages.nix | 2 +- modules/colorscheme/integrations/sway.nix | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/home/linux/gui/sway/values/packages.nix b/home/linux/gui/sway/values/packages.nix index bbd86680..3c86b40f 100644 --- a/home/linux/gui/sway/values/packages.nix +++ b/home/linux/gui/sway/values/packages.nix @@ -4,6 +4,6 @@ wl-clipboard libappindicator-gtk3 networkmanagerapplet - bemenu + wmenu ]; } diff --git a/modules/colorscheme/integrations/sway.nix b/modules/colorscheme/integrations/sway.nix index 2d6eb6f9..24d98c46 100644 --- a/modules/colorscheme/integrations/sway.nix +++ b/modules/colorscheme/integrations/sway.nix @@ -63,18 +63,13 @@ home.file.".local/bin/launcher".text = '' #!/usr/bin/env bash - ${pkgs.bemenu}/bin/bemenu-run -H 25 -p "" \ - --tb "${colorscheme.colors.altbg}" \ - --fb "${colorscheme.colors.altbg}" \ - --fbb "${colorscheme.colors.altbg}" \ - --nb "${colorscheme.colors.altbg}" \ - --nf "${colorscheme.colors.fg}" \ - --af "${colorscheme.colors.fg}" \ - --ab "${colorscheme.colors.altbg}" \ - --sb "${colorscheme.colors.altbg}" \ - --sf "${colorscheme.colors.fg}" \ - --hb "${colorscheme.colors.altbg}" \ - --hf "${colorscheme.colors.primary}" + ${pkgs.wmenu}/bin/wmenu-run -p "" \ + -M "${colorscheme.colors.altbg}" \ + -m "${colorscheme.colors.fg}" \ + -N "${colorscheme.colors.altbg}" \ + -n "${colorscheme.colors.fg}" \ + -S "${colorscheme.colors.altbg}" \ + -s "${colorscheme.colors.primary}" ''; home.file.".local/bin/launcher".executable = true; } From 78e20ea82c0fecfa0f1eb389d3529a5023eb6893 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 16:47:16 -0300 Subject: [PATCH 16/27] chore: add hardware acceleration option although chrome is still buggy --- modules/nixos/desktop.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nixos/desktop.nix b/modules/nixos/desktop.nix index 91b8d642..69372ee5 100644 --- a/modules/nixos/desktop.nix +++ b/modules/nixos/desktop.nix @@ -46,7 +46,7 @@ in { pathsToLink = ["/libexec"]; loginShellInit = '' if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then - exec sway --unsupported-gpu + exec sway --unsupported-gpu -Dlegacy-wl-drm fi ''; }; From ef701b939b4e5a3e6c391be258c948c716c6478d Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sat, 18 Jan 2025 17:00:23 -0300 Subject: [PATCH 17/27] refactor: add titles back :3 --- hosts/dtsf-pc/home/default.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index 968f42c4..d5f1fe9c 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -59,10 +59,6 @@ command = "floating enable, sticky enable"; criteria = {title = "^win";}; } - { - command = "title_format \" \""; - criteria = {title = "^.*$";}; - } ]; input = { From f08b6ca83111e9cf2441ec00751d091240771ca6 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 02:12:59 -0300 Subject: [PATCH 18/27] feat: add astal for sway bar integration not easy setup, doing some bad patterns :( --- flake.lock | 22 ++ flake.nix | 4 + hosts/dtsf-pc/home/default.nix | 5 + modules/colorscheme/home.nix | 13 ++ modules/colorscheme/integrations/astal.nix | 20 ++ modules/colorscheme/integrations/sway.nix | 35 ++-- modules/nupkgs/astal/conf/init.lua | 71 +++++++ modules/nupkgs/astal/conf/styles.scss | 91 ++++++++ modules/nupkgs/astal/conf/widget/Bar.lua | 231 +++++++++++++++++++++ modules/nupkgs/astal/default.nix | 32 +++ modules/nupkgs/default.nix | 13 +- outputs/x86_64-linux/src/dtsf-pc.nix | 3 +- templates/flake.template.nix | 1 + 13 files changed, 526 insertions(+), 15 deletions(-) create mode 100644 modules/colorscheme/integrations/astal.nix create mode 100644 modules/nupkgs/astal/conf/init.lua create mode 100644 modules/nupkgs/astal/conf/styles.scss create mode 100644 modules/nupkgs/astal/conf/widget/Bar.lua create mode 100644 modules/nupkgs/astal/default.nix diff --git a/flake.lock b/flake.lock index a7a847e4..d62c007c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "astal": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737220546, + "narHash": "sha256-xFoKn3cnFhE5f/J5c1Ey0We2RmrnZJDfzh1M0ZvyLh8=", + "owner": "aylur", + "repo": "astal", + "rev": "8b8416101246b4cce569f4326f828e26f15f6616", + "type": "github" + }, + "original": { + "owner": "aylur", + "ref": "main", + "repo": "astal", + "type": "github" + } + }, "datsnvim": { "inputs": { "flake-utils": "flake-utils", @@ -354,6 +375,7 @@ }, "root": { "inputs": { + "astal": "astal", "datsnvim": "datsnvim", "home-manager": "home-manager", "linux-shimeji": "linux-shimeji", diff --git a/flake.nix b/flake.nix index 8c633a17..8fbb1215 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,10 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + astal = { + inputs.nixpkgs.follows = "nixpkgs"; + url = "github:aylur/astal/main"; + }; datsnvim = { inputs = { home-manager.follows = "home-manager"; diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index d5f1fe9c..b340a565 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -1,5 +1,6 @@ { pkgs, + mypkgs, lib, ... }: { @@ -80,4 +81,8 @@ AddKeysToAgent yes ''; }; + + modules.desktop.nupkgs.packages = with mypkgs; [ + astal + ]; } diff --git a/modules/colorscheme/home.nix b/modules/colorscheme/home.nix index ffb4f5fa..99ffe472 100644 --- a/modules/colorscheme/home.nix +++ b/modules/colorscheme/home.nix @@ -70,6 +70,10 @@ type = lib.types.bool; default = false; }; + enableAstalIntegration = lib.mkOption { + type = lib.types.bool; + default = false; + }; }; config = let @@ -114,6 +118,7 @@ inherit lib pkgs; colorscheme = colorscheme; enableI3StatusIntegration = config.modules.desktop.colorscheme.enableI3StatusIntegration; + enableAstalIntegration = config.modules.desktop.colorscheme.enableAstalIntegration; }) ) @@ -162,6 +167,14 @@ colorscheme = colorscheme; }) ) + + ( + lib.mkIf config.modules.desktop.colorscheme.enableAstalIntegration + (import ./integrations/astal.nix { + inherit mylib; + colorscheme = colorscheme; + }) + ) ])) ]; } diff --git a/modules/colorscheme/integrations/astal.nix b/modules/colorscheme/integrations/astal.nix new file mode 100644 index 00000000..3eb831b9 --- /dev/null +++ b/modules/colorscheme/integrations/astal.nix @@ -0,0 +1,20 @@ +{ + colorscheme, + mylib, + ... +}: { + home.file.".local/share/astal/variables.scss".source = builtins.toFile "variables.scss" '' + $primary: ${colorscheme.colors.primary}; + $bg: ${(mylib.color.darkenHex colorscheme.colors.bg 0.8)}; + $altbg: ${colorscheme.colors.altbg}; + $fg: ${colorscheme.colors.fg}; + $black: ${colorscheme.colors.black}; + $red: ${colorscheme.colors.red}; + $green: ${colorscheme.colors.green}; + $yellow: ${colorscheme.colors.yellow}; + $blue: ${colorscheme.colors.blue}; + $magenta: ${colorscheme.colors.magenta}; + $cyan: ${colorscheme.colors.cyan}; + $white: ${colorscheme.colors.white}; + ''; +} diff --git a/modules/colorscheme/integrations/sway.nix b/modules/colorscheme/integrations/sway.nix index 24d98c46..896f86bd 100644 --- a/modules/colorscheme/integrations/sway.nix +++ b/modules/colorscheme/integrations/sway.nix @@ -3,6 +3,7 @@ colorscheme, pkgs, enableI3StatusIntegration, + enableAstalIntegration, ... }: { wayland.windowManager.sway.config = { @@ -37,19 +38,29 @@ text = colorscheme.colors.fg; }; }; - bars = [ - { - id = "bar-0"; - statusCommand = lib.mkIf enableI3StatusIntegration "i3status"; - colors = { - focusedWorkspace = { - background = "${colorscheme.colors.altbg}"; - border = "${colorscheme.colors.altbg}cc"; - text = "${colorscheme.colors.fg}"; + bars = + if enableI3StatusIntegration + then [ + { + id = "bar-0"; + statusCommand = lib.mkIf enableI3StatusIntegration "i3status"; + colors = { + focusedWorkspace = { + background = "${colorscheme.colors.altbg}"; + border = "${colorscheme.colors.altbg}cc"; + text = "${colorscheme.colors.fg}"; + }; }; - }; - } - ]; + } + ] + else if enableAstalIntegration + then [ + { + id = "bar-0"; + command = "astal"; + } + ] + else []; }; programs.i3status = lib.mkIf enableI3StatusIntegration { diff --git a/modules/nupkgs/astal/conf/init.lua b/modules/nupkgs/astal/conf/init.lua new file mode 100644 index 00000000..6ac059b2 --- /dev/null +++ b/modules/nupkgs/astal/conf/init.lua @@ -0,0 +1,71 @@ +local astal = require("astal") +local App = require("astal.gtk3.app") +local Bar = require("widget.Bar") + +local function file_exists(path) + local file = io.open(path, "r") + if file then + file:close() + return true + end + return false +end + +local function get_src(path) + local str = debug.getinfo(2, "S").source:sub(2) + local src = str:match("(.*/)") or str:match("(.*\\)") or "./" + return src .. path +end + +local scss = "/tmp/modified_styles.scss" +local css = "/tmp/style.css" + +local styles = get_src("styles.scss") +local replacement_file = os.getenv("HOME") .. "/.local/share/astal/variables.scss" + +local input = io.open(styles, "r") +local output = io.open(scss, "w") + +if file_exists(replacement_file) then + local replacement = io.open(replacement_file, "r") + if not replacement or not output then + error("Could not open " .. replacement_file .. " or " .. scss) + end + + local replacement_content = replacement:read("*a") + replacement:close() + output:write(replacement_content) + + local line_count = 0 + if not input then + error("Could not open " .. styles) + end + + for line in input:lines() do + line_count = line_count + 1 + if line_count > 12 then + output:write(line .. "\n") + end + end +else + if not output or not input then + error("Could not open " .. scss .. " or " .. styles) + end + + for line in input:lines() do + output:write(line .. "\n") + end +end + +input:close() +output:close() + +astal.exec("sass " .. scss .. " " .. css) + +App:start({ + instance_name = "lua", + css = css, + main = function() + Bar(1) + end, +}) diff --git a/modules/nupkgs/astal/conf/styles.scss b/modules/nupkgs/astal/conf/styles.scss new file mode 100644 index 00000000..e04a2cae --- /dev/null +++ b/modules/nupkgs/astal/conf/styles.scss @@ -0,0 +1,91 @@ +$primary: #a3be8c; +$bg: #282c34; +$altbg: #3e4451; +$fg: #abb2bf; +$black: #282c34; +$red: #bf616a; +$green: #a3be8c; +$yellow: #ebcb8b; +$blue: #81a1c1; +$magenta: #b48ead; +$cyan: #88c0d0; +$white: #e5e9f0; + +* { + all: unset; +} + +label { + font-weight: bold; +} + +progress, highlight { + background: $primary; + min-height: 7px; + border-radius: 4px; +} + +slider { + box-shadow: none; + background-color: $primary; + outline: 1px solid $altbg; + border-radius: 6px; + min-height: 7px; +} + +.bar { + color: $fg; + font-size: 12px; + background: transparent; +} + +.body { + background: $bg; + padding: 2px 4px; +} + +.tray { + margin-right: 12px; +} + +.tray button { + background: transparent; + border: none; + margin-left: 12px; +} + +.workspaces button { + background: transparent; + margin: 0 4px; + padding: 2px 6px; +} + +.workspaces button.focused { + background: $primary; + color: $bg; +} + +.workspaces button.occupied { + background: $altbg; +} + +.client-title { + margin-left: 1em; + color: $primary; +} + +.volume { + min-width: 90px; + margin-right: 12px; +} + +.volume button { + border: 1px solid transparent; + outline: none; + background: transparent; + margin-right: 12px; +} + +.clock { + margin-right: 12px; +} diff --git a/modules/nupkgs/astal/conf/widget/Bar.lua b/modules/nupkgs/astal/conf/widget/Bar.lua new file mode 100644 index 00000000..6a173f1f --- /dev/null +++ b/modules/nupkgs/astal/conf/widget/Bar.lua @@ -0,0 +1,231 @@ +local astal = require("astal") +local Widget = require("astal.gtk3.widget") +local Variable = astal.Variable +local bind = astal.bind +local GLib = astal.require("GLib") +local Wp = astal.require("AstalWp") +local Tray = astal.require("AstalTray") + +local arr_labels_in_japanese = { + "一", + "二", + "三", + "四", + "五", + "六", + "七", + "八", + "九", + "十", +} + +local function map(arr, fn) + local result = {} + for i, v in ipairs(arr) do + table.insert(result, fn(v, i)) + end + return result +end + +local function get_sway_socket() + return os.getenv("SWAYSOCK") +end + +local function execute_sway_command(cmd) + local socket = get_sway_socket() + if socket then + os.execute(string.format("swaymsg -s %s '%s'", socket, cmd)) + end +end + +local function create_workspace_monitor() + local active_workspace = Variable(1) + + local function update_workspaces() + local handle_active_workspace = io.popen("swaymsg -t get_workspaces | jq '.[] | select(.focused==true) | .num'") + + if handle_active_workspace then + local result_active_workspace = handle_active_workspace:read("*a") + handle_active_workspace:close() + active_workspace:set(tonumber(result_active_workspace)) + end + end + + GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, function() + update_workspaces() + return true + end) + + update_workspaces() + return active_workspace +end + +local function VolumeSlider(type) + local audio = Wp.get_default().audio + local device = type == "speaker" and audio.default_speaker or audio.default_source + + return Widget.Slider({ + hexpand = true, + draw_value = false, + on_value_changed = function(self) + device.volume = self.value + end, + value = bind(device, "volume"), + }) +end + +local function VolumeIndicator(type) + local audio = Wp.get_default().audio + local device = type == "speaker" and audio.default_speaker or audio.default_source + + if not device then + return Widget.Box({}) + end + + return Widget.Button({ + Widget.Icon({ + icon = bind(device, "volume-icon"):as(function(_) + return type == "speaker" and "audio-speakers-symbolic" or "audio-headphones-symbolic" + end), + }), + }) +end + +local function Volume() + return Widget.Box({ + class_name = "volume", + VolumeIndicator("speaker"), + VolumeSlider("speaker"), + }) +end + +local function Workspaces() + local active_workspace = create_workspace_monitor() + + return Widget.Box({ + class_name = "workspaces", + bind(active_workspace):as(function(a) + local children = {} + for i = 1, 10 do + table.insert( + children, + Widget.Button({ + on_clicked = function() + execute_sway_command(string.format("workspace number %d", i)) + end, + label = arr_labels_in_japanese[i], + class_name = a == i and "focused" or "", + }) + ) + end + return children + end), + }) +end + +local function Clock() + local time = Variable(""):poll(1000, function() + return GLib.DateTime.new_now_local():format("%a. %b %e - %H:%M:%S") + end) + + return Widget.Label({ + class_name = "clock", + on_destroy = function() + time:drop() + end, + label = time(), + }) +end + +local function SysTray() + local tray = Tray.get_default() + + return Widget.Box({ + class_name = "tray", + bind(tray, "items"):as(function(items) + return map(items, function(item) + return Widget.Button({ + Widget.Icon({ + gicon = bind(item, "gicon"), + }), + on_primary_click = function(_, event) + item:activate(event) + end, + on_secondary_click = function(_, event) + item:open_menu(event) + end, + tooltip_markup = bind(item, "tooltip-markup"), + }) + end) + end), + }) +end + +local function ClientTitle() + local title = Variable("") + + local function update_title() + local handle = io.popen("swaymsg -t get_tree | jq -r '.. | select(.focused?) | .name'") + if handle then + local result = handle:read("*a") + handle:close() + local value = result:gsub("^%s*(.-)%s*$", "%1") + if not tonumber(value) then + title:set(value) + else + title:set("") + end + end + end + + GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, function() + update_title() + return true + end) + + return Widget.Label({ + class_name = "client-title", + ellipsize = "END", + max_width_chars = 56, + label = title(), + }) +end + +local function Left() + return Widget.Box({ + Workspaces(), + }) +end + +local function Center() + return Widget.Box({ + ClientTitle(), + }) +end + +local function Right() + return Widget.Box({ + halign = "END", + SysTray(), + Volume(), + Clock(), + }) +end + +return function(monitor) + local WindowAnchor = astal.require("Astal", "3.0").WindowAnchor + + return Widget.Window({ + name = "bar-" .. monitor, + class_name = "bar", + monitor = monitor, + anchor = WindowAnchor.BOTTOM + WindowAnchor.LEFT + WindowAnchor.RIGHT, + exclusivity = "EXCLUSIVE", + Widget.CenterBox({ + class_name = "body", + start_widget = Left(), + center_widget = Center(), + end_widget = Right(), + }), + }) +end diff --git a/modules/nupkgs/astal/default.nix b/modules/nupkgs/astal/default.nix new file mode 100644 index 00000000..42453b24 --- /dev/null +++ b/modules/nupkgs/astal/default.nix @@ -0,0 +1,32 @@ +{ + lib, + astal, + stdenv, + dart-sass, + stdenvNoCC, + wrapGAppsHook, + gobject-introspection, + lua, + ... +}: let + platform = + if stdenv.hostPlatform.system == "x86_64-linux" + then stdenv.hostPlatform.system + else throw "Unsupported system"; +in + astal.lib.mkLuaPackage { + pkgs = + { + inherit lib stdenvNoCC wrapGAppsHook gobject-introspection lua; + } + // {system = platform;}; + name = "astal"; + src = ./conf; + + extraPackages = [ + astal.packages.${platform}.battery + astal.packages.${platform}.wireplumber + astal.packages.${platform}.tray + dart-sass + ]; + } diff --git a/modules/nupkgs/default.nix b/modules/nupkgs/default.nix index 3e8e32de..487a90d4 100644 --- a/modules/nupkgs/default.nix +++ b/modules/nupkgs/default.nix @@ -2,6 +2,7 @@ lib, pkgs, mylib, + astal, zellij-switch, linux-shimeji, ... @@ -16,9 +17,17 @@ packages = builtins.listToAttrs ( map - (file: { + (file: let name = lib.strings.removeSuffix ".nix" (baseNameOf file); - value = pkgsWithOverlays.callPackage file {}; + in { + name = name; + value = pkgsWithOverlays.callPackage file ( + if name == "astal" + then { + inherit astal; + } + else {} + ); }) packageFiles ) diff --git a/outputs/x86_64-linux/src/dtsf-pc.nix b/outputs/x86_64-linux/src/dtsf-pc.nix index 9632889d..7053594c 100644 --- a/outputs/x86_64-linux/src/dtsf-pc.nix +++ b/outputs/x86_64-linux/src/dtsf-pc.nix @@ -59,13 +59,14 @@ enableNeovimIntegration = true; enableGTKIntegration = true; enableSwayIntegration = true; - enableI3StatusIntegration = true; + enableI3StatusIntegration = false; enableDunstIntegration = true; enableAlacrittyIntegration = true; enableFishIntegration = true; enableCavaIntegration = true; enableZellijIntegration = true; enableGhosttyIntegration = false; + enableAstalIntegration = true; }; } ] diff --git a/templates/flake.template.nix b/templates/flake.template.nix index dcb08fd3..e61fc811 100644 --- a/templates/flake.template.nix +++ b/templates/flake.template.nix @@ -43,6 +43,7 @@ in home-manager = ext "github:nix-community/home-manager/master"; sops-nix = ext "github:Mic92/sops-nix/master"; neovim-nightly = ext "github:nix-community/neovim-nightly-overlay/master"; + astal = ext "github:aylur/astal/main"; datsnvim = ext-hm "github:datsfilipe/datsnvim/main"; unix-scripts = local ../home/linux/base/scripts/conf; }; From 3f45f39b6c985a6d326569a7604193e7a6aa198d Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 02:29:19 -0300 Subject: [PATCH 19/27] fix: flameshot for wayland --- home/linux/gui/base/misc.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/home/linux/gui/base/misc.nix b/home/linux/gui/base/misc.nix index 50868b2e..40e99e00 100644 --- a/home/linux/gui/base/misc.nix +++ b/home/linux/gui/base/misc.nix @@ -5,8 +5,21 @@ }: { home.packages = with pkgs; [ telegram-desktop - flameshot pcmanfm + grim + (flameshot.overrideAttrs (oldAttrs: { + src = pkgs.fetchFromGitHub { + owner = "flameshot-org"; + repo = "flameshot"; + rev = "3d21e4967b68e9ce80fb2238857aa1bf12c7b905"; + sha256 = "sha256-OLRtF/yjHDN+sIbgilBZ6sBZ3FO6K533kFC1L2peugc="; + }; + cmakeFlags = [ + "-DUSE_WAYLAND_CLIPBOARD=1" + "-DUSE_WAYLAND_GRIM=1" + ]; + buildInputs = oldAttrs.buildInputs ++ [pkgs.libsForQt5.kguiaddons]; + })) ]; fonts.fontconfig.enable = false; From 6cc7687f7ede139b5024ed7c48a4699a0aa54790 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 02:32:17 -0300 Subject: [PATCH 20/27] fix: correct sys tray --- modules/colorscheme/home.nix | 1 - modules/colorscheme/integrations/astal.nix | 8 ++------ modules/nupkgs/astal/conf/styles.scss | 4 ++++ modules/nupkgs/astal/conf/widget/Bar.lua | 15 +++++++-------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/modules/colorscheme/home.nix b/modules/colorscheme/home.nix index 99ffe472..f7f20139 100644 --- a/modules/colorscheme/home.nix +++ b/modules/colorscheme/home.nix @@ -171,7 +171,6 @@ ( lib.mkIf config.modules.desktop.colorscheme.enableAstalIntegration (import ./integrations/astal.nix { - inherit mylib; colorscheme = colorscheme; }) ) diff --git a/modules/colorscheme/integrations/astal.nix b/modules/colorscheme/integrations/astal.nix index 3eb831b9..97b1cda9 100644 --- a/modules/colorscheme/integrations/astal.nix +++ b/modules/colorscheme/integrations/astal.nix @@ -1,11 +1,7 @@ -{ - colorscheme, - mylib, - ... -}: { +{colorscheme, ...}: { home.file.".local/share/astal/variables.scss".source = builtins.toFile "variables.scss" '' $primary: ${colorscheme.colors.primary}; - $bg: ${(mylib.color.darkenHex colorscheme.colors.bg 0.8)}; + $bg: ${colorscheme.colors.bg}; $altbg: ${colorscheme.colors.altbg}; $fg: ${colorscheme.colors.fg}; $black: ${colorscheme.colors.black}; diff --git a/modules/nupkgs/astal/conf/styles.scss b/modules/nupkgs/astal/conf/styles.scss index e04a2cae..8fb32588 100644 --- a/modules/nupkgs/astal/conf/styles.scss +++ b/modules/nupkgs/astal/conf/styles.scss @@ -89,3 +89,7 @@ slider { .clock { margin-right: 12px; } + +.tray { + margin-right: 12px; +} diff --git a/modules/nupkgs/astal/conf/widget/Bar.lua b/modules/nupkgs/astal/conf/widget/Bar.lua index 6a173f1f..e85f567e 100644 --- a/modules/nupkgs/astal/conf/widget/Bar.lua +++ b/modules/nupkgs/astal/conf/widget/Bar.lua @@ -144,17 +144,16 @@ local function SysTray() class_name = "tray", bind(tray, "items"):as(function(items) return map(items, function(item) - return Widget.Button({ + return Widget.MenuButton({ + tooltip_markup = bind(item, "tooltip_markup"), + use_popover = false, + menu_model = bind(item, "menu-model"), + action_group = bind(item, "action-group"):as(function(ag) + return { "dbusmenu", ag } + end), Widget.Icon({ gicon = bind(item, "gicon"), }), - on_primary_click = function(_, event) - item:activate(event) - end, - on_secondary_click = function(_, event) - item:open_menu(event) - end, - tooltip_markup = bind(item, "tooltip-markup"), }) end) end), From 18fc2d49b96898b29c01a2077802b9d8db722af2 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 02:41:39 -0300 Subject: [PATCH 21/27] fix: update styles for tray menus --- modules/nupkgs/astal/conf/styles.scss | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/nupkgs/astal/conf/styles.scss b/modules/nupkgs/astal/conf/styles.scss index 8fb32588..a8c56ae5 100644 --- a/modules/nupkgs/astal/conf/styles.scss +++ b/modules/nupkgs/astal/conf/styles.scss @@ -33,6 +33,28 @@ slider { min-height: 7px; } +menu { + background: $bg; + padding: 8px; + + separator { + background: transparent; + } + + menuitem { + padding: 4px 2px; + border: 1px solid transparent; + margin: 4px 0; + &:first-child { margin-top: 0; } + &:last-child { margin-bottom: 0; } + + &:hover { + background: $altbg; + border: 1px solid $black; + } + } +} + .bar { color: $fg; font-size: 12px; From cfe9f8659fa41dc06b3758e020413271191a953b Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 08:07:06 -0300 Subject: [PATCH 22/27] feat: add utils --- modules/nupkgs/astal/conf/init.lua | 20 +------ modules/nupkgs/astal/conf/utils.lua | 52 ++++++++++++++++++ modules/nupkgs/astal/conf/widget/Bar.lua | 70 ++++++++++-------------- 3 files changed, 84 insertions(+), 58 deletions(-) create mode 100644 modules/nupkgs/astal/conf/utils.lua diff --git a/modules/nupkgs/astal/conf/init.lua b/modules/nupkgs/astal/conf/init.lua index 6ac059b2..94aff1c4 100644 --- a/modules/nupkgs/astal/conf/init.lua +++ b/modules/nupkgs/astal/conf/init.lua @@ -1,32 +1,18 @@ local astal = require("astal") local App = require("astal.gtk3.app") local Bar = require("widget.Bar") - -local function file_exists(path) - local file = io.open(path, "r") - if file then - file:close() - return true - end - return false -end - -local function get_src(path) - local str = debug.getinfo(2, "S").source:sub(2) - local src = str:match("(.*/)") or str:match("(.*\\)") or "./" - return src .. path -end +local utils = require("utils") local scss = "/tmp/modified_styles.scss" local css = "/tmp/style.css" -local styles = get_src("styles.scss") +local styles = utils.get_src("styles.scss") local replacement_file = os.getenv("HOME") .. "/.local/share/astal/variables.scss" local input = io.open(styles, "r") local output = io.open(scss, "w") -if file_exists(replacement_file) then +if utils.file_exists(replacement_file) then local replacement = io.open(replacement_file, "r") if not replacement or not output then error("Could not open " .. replacement_file .. " or " .. scss) diff --git a/modules/nupkgs/astal/conf/utils.lua b/modules/nupkgs/astal/conf/utils.lua new file mode 100644 index 00000000..ed5b6a90 --- /dev/null +++ b/modules/nupkgs/astal/conf/utils.lua @@ -0,0 +1,52 @@ +local M = {} + +M.TIMEOUT = 50 + +M.arr_labels_in_japanese = { + "一", + "二", + "三", + "四", + "五", + "六", + "七", + "八", + "九", + "十", +} + +function M.map(arr, fn) + result = {} + for i, v in ipairs(arr) do + table.insert(result, fn(v, i)) + end + return result +end + +function M.get_sway_socket() + return os.getenv("SWAYSOCK") +end + +function M.execute_sway_command(cmd) + local socket = M.get_sway_socket() + if socket then + os.execute(string.format("swaymsg -s %s '%s'", socket, cmd)) + end +end + +function M.get_src(path) + local str = debug.getinfo(2, "S").source:sub(2) + local src = str:match("(.*/)") or str:match("(.*\\)") or "./" + return src .. path +end + +function M.file_exists(path) + local file = io.open(path, "r") + if file then + file:close() + return true + end + return false +end + +return M diff --git a/modules/nupkgs/astal/conf/widget/Bar.lua b/modules/nupkgs/astal/conf/widget/Bar.lua index e85f567e..c4c753e2 100644 --- a/modules/nupkgs/astal/conf/widget/Bar.lua +++ b/modules/nupkgs/astal/conf/widget/Bar.lua @@ -5,59 +5,40 @@ local bind = astal.bind local GLib = astal.require("GLib") local Wp = astal.require("AstalWp") local Tray = astal.require("AstalTray") - -local arr_labels_in_japanese = { - "一", - "二", - "三", - "四", - "五", - "六", - "七", - "八", - "九", - "十", -} - -local function map(arr, fn) - local result = {} - for i, v in ipairs(arr) do - table.insert(result, fn(v, i)) - end - return result -end - -local function get_sway_socket() - return os.getenv("SWAYSOCK") -end - -local function execute_sway_command(cmd) - local socket = get_sway_socket() - if socket then - os.execute(string.format("swaymsg -s %s '%s'", socket, cmd)) - end -end +local utils = require("utils") local function create_workspace_monitor() local active_workspace = Variable(1) + local occupied_workspaces = Variable({}) local function update_workspaces() local handle_active_workspace = io.popen("swaymsg -t get_workspaces | jq '.[] | select(.focused==true) | .num'") + local handle_occupied_workspaces = io.popen("swaymsg -t get_workspaces | jq '.[].num'") - if handle_active_workspace then + if handle_active_workspace and handle_occupied_workspaces then local result_active_workspace = handle_active_workspace:read("*a") + local result_occupied_workspaces = handle_occupied_workspaces:read("*a") + handle_active_workspace:close() + handle_occupied_workspaces:close() + active_workspace:set(tonumber(result_active_workspace)) + + local workspaces = {} + for i in result_occupied_workspaces:gmatch("%d+") do + table.insert(workspaces, tonumber(i)) + end + occupied_workspaces:set(workspaces) end end - GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, function() + GLib.timeout_add(GLib.PRIORITY_DEFAULT, utils.TIMEOUT, function() update_workspaces() return true end) update_workspaces() - return active_workspace + return active_workspace, occupied_workspaces end local function VolumeSlider(type) @@ -100,7 +81,7 @@ local function Volume() end local function Workspaces() - local active_workspace = create_workspace_monitor() + local active_workspace, occupied_workspaces = create_workspace_monitor() return Widget.Box({ class_name = "workspaces", @@ -111,10 +92,17 @@ local function Workspaces() children, Widget.Button({ on_clicked = function() - execute_sway_command(string.format("workspace number %d", i)) + utils.execute_sway_command(string.format("workspace number %d", i)) end, - label = arr_labels_in_japanese[i], - class_name = a == i and "focused" or "", + label = utils.arr_labels_in_japanese[i], + class_name = (function() + if a == i then + return "focused" + elseif occupied_workspaces:get()[i] then + return "occupied" + end + return "" + end)(), }) ) end @@ -143,7 +131,7 @@ local function SysTray() return Widget.Box({ class_name = "tray", bind(tray, "items"):as(function(items) - return map(items, function(item) + return utils.map(items, function(item) return Widget.MenuButton({ tooltip_markup = bind(item, "tooltip_markup"), use_popover = false, @@ -177,7 +165,7 @@ local function ClientTitle() end end - GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, function() + GLib.timeout_add(GLib.PRIORITY_DEFAULT, utils.TIMEOUT, function() update_title() return true end) From e880c3990d6d4a3c3e15789c5341730f48ee8563 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 08:10:38 -0300 Subject: [PATCH 23/27] refactor: use config to decide about flameshot package --- home/linux/gui/base/misc.nix | 45 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/home/linux/gui/base/misc.nix b/home/linux/gui/base/misc.nix index 40e99e00..fe60a541 100644 --- a/home/linux/gui/base/misc.nix +++ b/home/linux/gui/base/misc.nix @@ -1,26 +1,35 @@ { + config, pkgs, pkgs-unstable, ... }: { - home.packages = with pkgs; [ - telegram-desktop - pcmanfm - grim - (flameshot.overrideAttrs (oldAttrs: { - src = pkgs.fetchFromGitHub { - owner = "flameshot-org"; - repo = "flameshot"; - rev = "3d21e4967b68e9ce80fb2238857aa1bf12c7b905"; - sha256 = "sha256-OLRtF/yjHDN+sIbgilBZ6sBZ3FO6K533kFC1L2peugc="; - }; - cmakeFlags = [ - "-DUSE_WAYLAND_CLIPBOARD=1" - "-DUSE_WAYLAND_GRIM=1" - ]; - buildInputs = oldAttrs.buildInputs ++ [pkgs.libsForQt5.kguiaddons]; - })) - ]; + home.packages = with pkgs; + [ + telegram-desktop + pcmanfm + ( + if config.modules.desktop.sway.enable + then + (flameshot.overrideAttrs (oldAttrs: { + src = pkgs.fetchFromGitHub { + owner = "flameshot-org"; + repo = "flameshot"; + rev = "3d21e4967b68e9ce80fb2238857aa1bf12c7b905"; + sha256 = "sha256-OLRtF/yjHDN+sIbgilBZ6sBZ3FO6K533kFC1L2peugc="; + }; + cmakeFlags = [ + "-DUSE_WAYLAND_CLIPBOARD=1" + "-DUSE_WAYLAND_GRIM=1" + ]; + buildInputs = oldAttrs.buildInputs ++ [pkgs.libsForQt5.kguiaddons]; + })) + else flameshot + ) + ] + ++ pkgs.lib.optionals config.modules.desktop.sway.enable [ + grim + ]; fonts.fontconfig.enable = false; } From 9d868075b34761cb48c6af3bf1738b8cbc45dd19 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 08:26:32 -0300 Subject: [PATCH 24/27] feat: add udiskie tray back --- hosts/dtsf-pc/home/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index b340a565..61be7ea3 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -24,7 +24,7 @@ keybindings = keymaps.allBindings; startup = [ - (command "udiskie --notify" true) + (command "udiskie --tray --notify" true) (command "swaymsg 'workspace 1'" false) (command "dunst -config $HOME/.config/dunstrc" true) (command "systemctl --user restart wallpaper.service" true) From 1d3aa7c476e84284f2ff6d7a8b55eec13ee7a350 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 08:28:27 -0300 Subject: [PATCH 25/27] refactor: update startup apps --- hosts/dtsf-pc/home/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosts/dtsf-pc/home/default.nix b/hosts/dtsf-pc/home/default.nix index 61be7ea3..2f34d49c 100644 --- a/hosts/dtsf-pc/home/default.nix +++ b/hosts/dtsf-pc/home/default.nix @@ -24,9 +24,9 @@ keybindings = keymaps.allBindings; startup = [ - (command "udiskie --tray --notify" true) + (command "udiskie --tray --notify" false) (command "swaymsg 'workspace 1'" false) - (command "dunst -config $HOME/.config/dunstrc" true) + (command "dunst -config $HOME/.config/dunstrc" false) (command "systemctl --user restart wallpaper.service" true) ]; From a6dc5530d3c97dfe5dd3ee14ffa400d531527135 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 08:30:31 -0300 Subject: [PATCH 26/27] docs: update README --- README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 543ebf67..e757c8c3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -> [!CAUTION] -> If you are using an NVIDIA GPU, it's worth knowing that my attempts to make it work with mine have been unsuccessful. -> So this configuration might not work for you as well. If you don't have an NVIDIA GPU, then you might try, but I can't confirm it will work either. -
# datsfilipe’s dotfiles @@ -81,10 +77,9 @@ - `nupkgs`: "nix user packages" - using that instead of a nur repo. - `secrets`: secrets module, using sops for encryption. - `wallpaper`: wallpaper definition. -- `outputs`: outputs of the dotfiles. -- `outputs`: Contains all the outputs of the dotfiles. -- `scripts`: Contains all the scripts used in the dotfiles. -- `vars`: Contains all the variables used in the dotfiles. +- `outputs`: outputs of the config. +- `scripts`: scripts used in the config. +- `vars`: variables used in the config. ### General slices From f592dcd98d90c9c598d43b141206a3508d4892e4 Mon Sep 17 00:00:00 2001 From: Filipe Lima Date: Sun, 19 Jan 2025 08:56:00 -0300 Subject: [PATCH 27/27] fix: occupied workspaces --- modules/nupkgs/astal/conf/utils.lua | 9 +++++++++ modules/nupkgs/astal/conf/widget/Bar.lua | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/nupkgs/astal/conf/utils.lua b/modules/nupkgs/astal/conf/utils.lua index ed5b6a90..46c526d0 100644 --- a/modules/nupkgs/astal/conf/utils.lua +++ b/modules/nupkgs/astal/conf/utils.lua @@ -49,4 +49,13 @@ function M.file_exists(path) return false end +function M.contains_value(tbl, value) + for _, v in ipairs(tbl) do + if v == value then + return true + end + end + return false +end + return M diff --git a/modules/nupkgs/astal/conf/widget/Bar.lua b/modules/nupkgs/astal/conf/widget/Bar.lua index c4c753e2..c3373bcb 100644 --- a/modules/nupkgs/astal/conf/widget/Bar.lua +++ b/modules/nupkgs/astal/conf/widget/Bar.lua @@ -95,14 +95,14 @@ local function Workspaces() utils.execute_sway_command(string.format("workspace number %d", i)) end, label = utils.arr_labels_in_japanese[i], - class_name = (function() + class_name = bind(occupied_workspaces):as(function(o) if a == i then return "focused" - elseif occupied_workspaces:get()[i] then + elseif utils.contains_value(o, i) then return "occupied" end return "" - end)(), + end), }) ) end