fixup sway and add mimeapps

This commit is contained in:
tristan 2024-01-08 02:12:09 +00:00
parent 879489efcb
commit 829c8d9392
9 changed files with 71 additions and 33 deletions

View file

@ -8,8 +8,28 @@ with lib; let
user = config.user;
cfg = config.displays;
renderDisplaysForHyprland = displays: (map displayHyprlandSetting (builtins.filter (d: d.enable) displays));
swaybgJob = displays: {
Unit = {
Description = "SwayBG";
};
Service = {
ExecStart =
"${pkgs.swaybg}/bin/swaybg "
+ builtins.concatStringsSep " " (map swaybgCmd displays);
};
Install = {
WantedBy = ["graphical-session.target"];
};
};
swaybgCmd = display:
if (display.enable && display ? wallpaper && display.wallpaper != null)
then "-o ${display.name} -i ${display.wallpaper} -m fill"
else "";
displayHyprlandSetting = display:
specificDisplay display
+ ", "
@ -22,25 +42,6 @@ with lib; let
+ "transform,"
+ toString display.rotation;
swaybgJob = displays: {
Unit = {
Description = "SwayBG";
};
Service = {
ExecStart =
"${pkgs.swaybg}/bin/swaybg "
+ concatStringsSep " " (map swaybgCmd displays);
};
Install = {
WantedBy = ["graphical-session.target"];
};
};
swaybgCmd = display:
if (display.wallpaper != "")
then "-o ${display.name} -i ${display.wallpaper} -m fill"
else "";
specificDisplay = display:
if display.description == ""
then display.name
@ -55,7 +56,7 @@ with lib; let
else toString x + "x" + toString y;
renderDisplaysForSway = displays:
listToAttrs (map displaySwaySetting displays);
listToAttrs (map displaySwaySetting (builtins.filter (d: d.enable) displays));
displaySwaySetting = display: {
name = display.name;
@ -65,9 +66,12 @@ with lib; let
mode =
mkIf (!resUnset res)
"${toString res.x}x${toString res.y}@${toString res.freq}Hz";
bg = display.wallpaper + " fill";
scale = toString display.scaling;
};
}
// lib.mkIf ( display ? wallpaper && display.wallpaper != null ) {
bg = "${ display.wallpaper } fill";
}
;
};
resolutionType = types.submodule {
@ -124,7 +128,7 @@ with lib; let
};
wallpaper = mkOption {
description = "path to wallpaper";
default = "";
default = null;
};
workspaces = mkOption {
default = {};
@ -173,10 +177,10 @@ in {
config = mkIf cfg.enable {
home-manager.users.${user}.imports = [
{
systemd.user.services.swaybg = swaybgJob (attrValues cfg.displays);
programs.waybar.settings.mainBar."hyprland/workspaces".persistent_workspaces = waybarWorkspaceConf (attrValues cfg.displays);
systemd.user.services.swaybg = swaybgJob (builtins.attrValues cfg.displays);
wayland.windowManager = mkIf (cfg.displays != {}) {
hyprland.settings = {
monitor = renderDisplaysForHyprland (attrValues cfg.displays);