display settings GUI
This commit is contained in:
parent
06e889c274
commit
f55fb2472c
7 changed files with 13 additions and 256 deletions
|
|
@ -1,29 +0,0 @@
|
||||||
{
|
|
||||||
displays = {
|
|
||||||
enable = true;
|
|
||||||
displays = {
|
|
||||||
"hp" = {
|
|
||||||
description = "HP Inc. HP 24x 1CR9500W9Q";
|
|
||||||
resolution = {
|
|
||||||
x = 1920;
|
|
||||||
y = 1080;
|
|
||||||
freq = 144;
|
|
||||||
};
|
|
||||||
position.x = 0;
|
|
||||||
position.y = 360;
|
|
||||||
};
|
|
||||||
"asus" = {
|
|
||||||
resolution = {
|
|
||||||
x = 1920;
|
|
||||||
y = 1080;
|
|
||||||
freq = 60;
|
|
||||||
};
|
|
||||||
position = {
|
|
||||||
x = 1920;
|
|
||||||
y = 0;
|
|
||||||
};
|
|
||||||
rotation = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -88,25 +88,4 @@ in {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
displays = {
|
|
||||||
displays."hp" = {
|
|
||||||
enable = true;
|
|
||||||
name = "DP-1";
|
|
||||||
wallpaper = ../images/demonslayer.png;
|
|
||||||
workspaces = {
|
|
||||||
start = 1;
|
|
||||||
end = 5;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
displays."asus" = {
|
|
||||||
enable = true;
|
|
||||||
name = "HDMI-A-1";
|
|
||||||
wallpaper = ../images/nier2.jpg;
|
|
||||||
workspaces = {
|
|
||||||
start = 6;
|
|
||||||
end = 10;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ in {
|
||||||
(import ../utils/swaylock.nix)
|
(import ../utils/swaylock.nix)
|
||||||
(import ../utils/swayidle.nix)
|
(import ../utils/swayidle.nix)
|
||||||
(import ../utils/waybar.nix)
|
(import ../utils/waybar.nix)
|
||||||
|
(import ../utils/display.nix)
|
||||||
];
|
];
|
||||||
xdg.portal = {
|
xdg.portal = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
||||||
7
home/desktop/utils/display.nix
Normal file
7
home/desktop/utils/display.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
pkgs, ...
|
||||||
|
}: {
|
||||||
|
home.packages = with pkgs; [wlr-randr nwg-displays];
|
||||||
|
|
||||||
|
wayland.windowManager.hyprland.settings.source = ["~/.config/hypr/monitors.conf"];
|
||||||
|
}
|
||||||
|
|
@ -8,10 +8,6 @@
|
||||||
}: let
|
}: let
|
||||||
user = config.user;
|
user = config.user;
|
||||||
in {
|
in {
|
||||||
imports = [
|
|
||||||
./modules/display.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
settings = {
|
settings = {
|
||||||
experimental-features = ["nix-command" "flakes"];
|
experimental-features = ["nix-command" "flakes"];
|
||||||
|
|
|
||||||
|
|
@ -1,197 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
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
|
|
||||||
+ ", "
|
|
||||||
+ resToString display.resolution
|
|
||||||
+ ", "
|
|
||||||
+ positionToHyprlandString display.position
|
|
||||||
+ ", "
|
|
||||||
+ toString display.scaling
|
|
||||||
+ ", "
|
|
||||||
+ "transform,"
|
|
||||||
+ toString display.rotation;
|
|
||||||
|
|
||||||
specificDisplay = display:
|
|
||||||
if display.description == ""
|
|
||||||
then display.name
|
|
||||||
else "desc:" + display.description;
|
|
||||||
|
|
||||||
positionToHyprlandString = {
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
}:
|
|
||||||
if (x == -1 || y == -1)
|
|
||||||
then "auto"
|
|
||||||
else toString x + "x" + toString y;
|
|
||||||
|
|
||||||
renderDisplaysForSway = displays:
|
|
||||||
listToAttrs (map displaySwaySetting (builtins.filter (d: d.enable) displays));
|
|
||||||
|
|
||||||
displaySwaySetting = display: {
|
|
||||||
name = display.name;
|
|
||||||
value = let
|
|
||||||
res = display.resolution;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
mode =
|
|
||||||
mkIf (!resUnset res)
|
|
||||||
"${toString res.x}x${toString res.y}@${toString res.freq}Hz";
|
|
||||||
scale = toString display.scaling;
|
|
||||||
}
|
|
||||||
// lib.mkIf (display ? wallpaper && display.wallpaper != null) {
|
|
||||||
bg = "${display.wallpaper} fill";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
resolutionType = types.submodule {
|
|
||||||
options = {
|
|
||||||
x = mkOption {
|
|
||||||
description = "x";
|
|
||||||
type = types.int;
|
|
||||||
default = 0;
|
|
||||||
};
|
|
||||||
y = mkOption {
|
|
||||||
description = "y";
|
|
||||||
type = types.int;
|
|
||||||
default = 0;
|
|
||||||
};
|
|
||||||
freq = mkOption {
|
|
||||||
description = "frequency";
|
|
||||||
type = types.int;
|
|
||||||
default = 0;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
displayType = types.submodule {
|
|
||||||
options = {
|
|
||||||
enable = mkEnableOption "enable this display";
|
|
||||||
name = mkOption {
|
|
||||||
description = "name of the display";
|
|
||||||
default = "";
|
|
||||||
};
|
|
||||||
description = mkOption {
|
|
||||||
description = "description of display from hyprctl monitors";
|
|
||||||
default = "";
|
|
||||||
};
|
|
||||||
scaling = mkOption {
|
|
||||||
type = types.float;
|
|
||||||
default = 1.0;
|
|
||||||
};
|
|
||||||
rotation = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 0;
|
|
||||||
};
|
|
||||||
resolution = mkOption {
|
|
||||||
description = "res";
|
|
||||||
type = resolutionType;
|
|
||||||
default = {};
|
|
||||||
};
|
|
||||||
position.x = mkOption {
|
|
||||||
default = -1;
|
|
||||||
type = types.int;
|
|
||||||
};
|
|
||||||
position.y = mkOption {
|
|
||||||
default = -1;
|
|
||||||
type = types.int;
|
|
||||||
};
|
|
||||||
wallpaper = mkOption {
|
|
||||||
description = "path to wallpaper";
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
workspaces = mkOption {
|
|
||||||
default = {};
|
|
||||||
type = types.submodule {
|
|
||||||
options = {
|
|
||||||
start = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 1;
|
|
||||||
};
|
|
||||||
end = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
resUnset = res: (res.x == 0 || res.y == 0 || res.freq == 0);
|
|
||||||
|
|
||||||
resToString = res:
|
|
||||||
if resUnset res
|
|
||||||
then "preferred"
|
|
||||||
else "${toString res.x}x${toString res.y}@${toString res.freq}";
|
|
||||||
|
|
||||||
waybarWorkspaceConf = monitors: (map (display: {
|
|
||||||
${display.name} = display.workspaces.start;
|
|
||||||
})
|
|
||||||
monitors);
|
|
||||||
|
|
||||||
renderWorkspacesForHyprland = displays: (map hyprWorkspaceSetting displays);
|
|
||||||
|
|
||||||
hyprWorkspaceSetting = display:
|
|
||||||
specificDisplay display
|
|
||||||
+ ", "
|
|
||||||
+ toString display.workspaces.start;
|
|
||||||
in {
|
|
||||||
options.displays = {
|
|
||||||
enable = mkEnableOption "manage displays";
|
|
||||||
displays = mkOption {
|
|
||||||
type = types.attrsOf displayType;
|
|
||||||
default = {};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
home-manager.users.${user}.imports = [
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
workspace = renderWorkspacesForHyprland (attrValues cfg.displays);
|
|
||||||
};
|
|
||||||
|
|
||||||
sway.config.output =
|
|
||||||
renderDisplaysForSway (attrValues cfg.displays);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{...}: {
|
||||||
...
|
|
||||||
}: {
|
|
||||||
services.anki-sync-server = {
|
services.anki-sync-server = {
|
||||||
enable = true;
|
enable = true;
|
||||||
address = "100.65.29.110";
|
address = "100.65.29.110";
|
||||||
users = [{
|
users = [
|
||||||
|
{
|
||||||
username = "tristan";
|
username = "tristan";
|
||||||
password = "password";
|
password = "password";
|
||||||
} ];
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue