Separated concerns in desktop environment
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.samfelag.modules.app.firefox;
|
cfg = config.samfelag.modules.app.firefox;
|
||||||
|
i3Cfg = config.samfelag.modules.desktop.i3;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.samfelag.modules.app.firefox = {
|
options.samfelag.modules.app.firefox = {
|
||||||
@@ -11,5 +12,9 @@ in
|
|||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
firefox
|
firefox
|
||||||
];
|
];
|
||||||
|
|
||||||
|
samfelag.modules.desktop.i3.extraKeybindings = lib.mkIf i3Cfg.enable {
|
||||||
|
"${i3Cfg.mod}+Control+3" = "exec ${pkgs.firefox}/bin/firefox";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.samfelag.modules.app.spotify;
|
cfg = config.samfelag.modules.app.spotify;
|
||||||
|
i3Cfg = config.samfelag.modules.desktop.i3;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.samfelag.modules.app.spotify = {
|
options.samfelag.modules.app.spotify = {
|
||||||
@@ -11,5 +12,9 @@ in
|
|||||||
hm.home.packages = with pkgs; [
|
hm.home.packages = with pkgs; [
|
||||||
spotify
|
spotify
|
||||||
];
|
];
|
||||||
|
|
||||||
|
samfelag.modules.desktop.i3.extraKeybindings = lib.mkIf i3Cfg.enable {
|
||||||
|
"${i3Cfg.mod}+Control+0" = "exec ${pkgs.spotify}/bin/spotify";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ in
|
|||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bgColour = my.mkOpt' types.str "#808F85" "Background colour for the wallpaper";
|
||||||
|
wallpapers = my.mkOpt' types.path ../../data/wallpapers/flors "Path to a folder containing wallpapers";
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
@@ -50,19 +53,22 @@ in
|
|||||||
|
|
||||||
samfelag.modules = {
|
samfelag.modules = {
|
||||||
|
|
||||||
# Basic
|
|
||||||
app.alacritty.enable = true;
|
app.alacritty.enable = true;
|
||||||
desktop.polybar.enable = true;
|
|
||||||
desktop.rofi.enable = true;
|
desktop.rofi.enable = true;
|
||||||
|
desktop.polybar.enable = true;
|
||||||
|
app.firefox.enable = true;
|
||||||
|
|
||||||
desktop.i3 = {
|
desktop.i3 = {
|
||||||
enable = true;
|
enable = true;
|
||||||
laptop = cfg.laptop;
|
laptop = cfg.laptop;
|
||||||
launcher.command = "${pkgs.rofi}/bin/rofi rofi -show run";
|
launcher = "${pkgs.rofi}/bin/rofi rofi -show run";
|
||||||
terminal.command = "${pkgs.alacritty}/bin/alacritty";
|
terminal = "${pkgs.alacritty}/bin/alacritty";
|
||||||
browser.command = "${pkgs.firefox}/bin/firefox";
|
locker = "${pkgs.i3lock-blur}/bin/i3lock-color -c 808F85 && sleep 1";
|
||||||
locker.command = "${pkgs.i3lock-blur}/bin/i3lock-color -c 808F85 && sleep 1";
|
|
||||||
app.firefox.enable = true;
|
extraStartup = [
|
||||||
|
{ command = "systemctl --user restart polybar"; always = true; notification = false; }
|
||||||
|
{ command = "feh --bg-center -B \"${cfg.bgColour}\" -z --no-fehbg ${cfg.wallpapers}"; always = true; notification = false; }
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,50 +4,24 @@ let
|
|||||||
cfg = config.samfelag.modules.desktop.i3;
|
cfg = config.samfelag.modules.desktop.i3;
|
||||||
mod = "Mod4";
|
mod = "Mod4";
|
||||||
|
|
||||||
cmdModule = lib.types.submodule ({ ... }: {
|
|
||||||
options = {
|
|
||||||
enable = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
command = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
example = "${pkgs.rofi}/bin/rofi rofi -show run";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
system_mode = "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown";
|
system_mode = "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown";
|
||||||
|
|
||||||
bg_colour = "#808F85";
|
|
||||||
|
|
||||||
paths = {
|
|
||||||
wallpapers = ../../data/wallpapers;
|
|
||||||
};
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
options.samfelag.modules.desktop.i3 = {
|
options.samfelag.modules.desktop.i3 = with lib; {
|
||||||
enable = lib.mkEnableOption "i3 window manager";
|
enable = mkEnableOption "i3 window manager";
|
||||||
|
|
||||||
laptop = lib.mkOption {
|
mod = my.mkOpt' types.str "Mod4" "Main modifier key for i3";
|
||||||
description = "Enable features for a laptop (trackpad, battery, etc...)";
|
|
||||||
type = lib.types.bool;
|
laptop = mkEnableOption "Enable features for a laptop (trackpad, battery, etc...)";
|
||||||
default = false;
|
|
||||||
};
|
launcher = mkOption { type = types.str; };
|
||||||
|
terminal = mkOption { type = types.str; };
|
||||||
|
locker = mkOption { type = types.str; };
|
||||||
|
|
||||||
|
extraKeybindings = my.mkOpt (types.attrsOf types.str) {};
|
||||||
|
extraStartup = my.mkOpt (types.listOf types.attrs) [ ];
|
||||||
|
|
||||||
launcher = lib.mkOption {
|
|
||||||
type = cmdModule;
|
|
||||||
};
|
|
||||||
terminal = lib.mkOption {
|
|
||||||
type = cmdModule;
|
|
||||||
};
|
|
||||||
browser = lib.mkOption {
|
|
||||||
type = cmdModule;
|
|
||||||
};
|
|
||||||
locker = lib.mkOption {
|
|
||||||
type = cmdModule;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
@@ -59,8 +33,6 @@ in {
|
|||||||
playerctl
|
playerctl
|
||||||
];
|
];
|
||||||
|
|
||||||
hm.xdg.dataFile."wallpapers".source = paths.wallpapers;
|
|
||||||
|
|
||||||
services.xserver = {
|
services.xserver = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
@@ -121,9 +93,7 @@ in {
|
|||||||
|
|
||||||
startup = [
|
startup = [
|
||||||
{ command = "i3-msg workspace 1"; }
|
{ command = "i3-msg workspace 1"; }
|
||||||
{ command = "systemctl --user restart polybar"; always = true; notification = false; }
|
] ++ cfg.extraStartup;
|
||||||
{ command = "feh --bg-center -B \"${bg_colour}\" -z --no-fehbg ${paths.wallpapers}/flors"; always = true; notification = false; }
|
|
||||||
];
|
|
||||||
|
|
||||||
modes = {
|
modes = {
|
||||||
"resize" = {
|
"resize" = {
|
||||||
@@ -142,10 +112,10 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
"${system_mode}" = {
|
"${system_mode}" = {
|
||||||
"l" = "exec --no-startup-id ${cfg.locker.command}, mode \"default\"";
|
"l" = "exec --no-startup-id ${cfg.locker}, mode \"default\"";
|
||||||
"e" = "exec --no-startup-id i3-msg exit, mode \"default\"";
|
"e" = "exec --no-startup-id i3-msg exit, mode \"default\"";
|
||||||
"s" = "exec --no-startup-id ${cfg.locker.command} && systemctl suspend, mode \"default\"";
|
"s" = "exec --no-startup-id ${cfg.locker} && systemctl suspend, mode \"default\"";
|
||||||
"h" = "exec --no-startup-id ${cfg.locker.command} && systemctl hibernate, mode \"default\"";
|
"h" = "exec --no-startup-id ${cfg.locker} && systemctl hibernate, mode \"default\"";
|
||||||
"r" = "exec --no-startup-id systemctl reboot, mode \"default\"";
|
"r" = "exec --no-startup-id systemctl reboot, mode \"default\"";
|
||||||
"Shift+s" = "exec --no-startup-id systemctl poweroff -i, mode \"default\"";
|
"Shift+s" = "exec --no-startup-id systemctl poweroff -i, mode \"default\"";
|
||||||
|
|
||||||
@@ -242,16 +212,9 @@ in {
|
|||||||
"${mod}+Shift+9" = "move container to workspace 9; workspace 9";
|
"${mod}+Shift+9" = "move container to workspace 9; workspace 9";
|
||||||
"${mod}+Shift+0" = "move container to workspace 10; workspace 10";
|
"${mod}+Shift+0" = "move container to workspace 10; workspace 10";
|
||||||
|
|
||||||
}
|
"${mod}+Return" = "exec ${cfg.terminal}";
|
||||||
// (if cfg.terminal.enable then {
|
"${mod}+space" = "exec ${cfg.launcher}";
|
||||||
"${mod}+Return" = "exec ${cfg.terminal.command}";
|
} // cfg.extraKeybindings;
|
||||||
} else {})
|
|
||||||
// (if cfg.launcher.enable then {
|
|
||||||
"${mod}+space" = "exec ${cfg.launcher.command}";
|
|
||||||
} else {})
|
|
||||||
// (if cfg.browser.enable then {
|
|
||||||
"${mod}+Control+3" = "exec ${cfg.browser.command}";
|
|
||||||
} else {});
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user