Skip to content

Commit

Permalink
fix(autostart): problem with install mutli window managers configurat…
Browse files Browse the repository at this point in the history
…ion at the same time

Problem was releated with conflict between 2 difference path to
autostart.sh script. I create list of path to the script and refactor
using of desktop.autostart module in all desktops
  • Loading branch information
Wittano committed Jan 24, 2025
1 parent ccabcfe commit 2027123
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 24 deletions.
42 changes: 30 additions & 12 deletions home-manager/autostart.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ let
_log_app "$app"
done
'';

autostartScript = mkAutostartScript "desktop" cfg.programs;
in
{
options = {
Expand All @@ -39,22 +41,38 @@ in
description = "List of programs used in autostart script";
default = [ ];
};
desktopName = mkOption {
type = with types; str;
description = "List of programs used in autostart script";
};
scriptPath = mkOption {
type = with types; nullOr str;
description = "Autostart script location. Default path is $HOME/.config/autostart.sh";
default = null;
paths = mkOption {
type = with types; listOf (nullOr str);
description = "List of locations of autostart script location. Default path is $HOME/.config/autostart.sh";
default = [ ];
};
};
};

config = mkIf cfg.enable {
home.file = mkIf (cfg.scriptPath != null) {
"${cfg.scriptPath}".source = mkAutostartScript cfg.desktopName cfg.programs;
};
xdg.configFile.${cfg.autostartPath or "autostart.sh"}.source = mkAutostartScript cfg.desktopName cfg.programs;
home.file = trivial.pipe cfg.paths [
(builtins.filter (x: x != null && x != ""))
(builtins.map (x: {
name = x;
value = {
source = autostartScript;
};
}))
builtins.listToAttrs
];
xdg.configFile =
if (cfg.paths != [ ]) then
trivial.pipe cfg.paths [
(builtins.filter (x: x == null || x == ""))
(builtins.map (x: {
name = x;
value = {
source = autostartScript;
};
}))
builtins.listToAttrs
] else {
"autostart.sh".source = autostartScript;
};
};
}
12 changes: 9 additions & 3 deletions hosts/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,15 @@ mkMerge [
interval = "21:37";
};

desktop."${desktopName}" = {
enable = true;
users = builtins.attrNames users.users;
desktop = {
openbox = {
enable = true;
users = [ "work" ];
};
"${desktopName}" = {
enable = true;
users = builtins.attrNames users.users;
};
};

# System
Expand Down
5 changes: 1 addition & 4 deletions nixos/desktop/bspwm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ in
home-manager.users = desktop.mkMultiUserHomeManager cfg.users {
home.packages = with pkgs; [ gsimplecal ];

desktop.autostart = {
desktopName = "bspwm";
programs = [ "wmname compiz" ];
};
desktop.autostart.programs = [ "wmname compiz" ];

serivces.polybar.wittano.profile = if cfg.deviceType == "pc" then "wittano" else "laptop";

Expand Down
4 changes: 2 additions & 2 deletions nixos/desktop/openbox/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ in

home-manager.users = desktop.mkMultiUserHomeManager cfg.users {
desktop.autostart = {
desktopName = "openbox";
scriptPath = ".config/openbox/autostart";
enable = true;
paths = [ ".config/openbox/autostart" ];
programs = [ "tint2" "volumeicon" ];
};
home = {
Expand Down
4 changes: 3 additions & 1 deletion nixos/desktop/qtile/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ in


home-manager.users = desktop.mkMultiUserHomeManager cfg.users {
desktop.autostart.desktopName = "qtile";
desktop.autostart.desktop = [{
name = "qtile";
}];

xdg.configFile."qtile".source = ./.;
};
Expand Down
2 changes: 0 additions & 2 deletions nixos/desktop/xmonad/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ in
environment.systemPackages = with pkgs; [ alsa-utils ];

home-manager.users = desktop.mkMultiUserHomeManager cfg.users {
desktop.autostart.desktopName = "xmonad";

programs.xmobar = {
enable = true;
package = unstable.xmobar;
Expand Down

0 comments on commit 2027123

Please sign in to comment.