2023-11-21 08:14:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.sane.programs.sway-autoscaler;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
sane.programs.sway-autoscaler = {
|
|
|
|
configOption = with lib; mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.submodule {
|
|
|
|
options.autostart = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
options.defaultScale = mkOption {
|
|
|
|
type = types.number;
|
|
|
|
default = 1;
|
|
|
|
};
|
|
|
|
options.interval = mkOption {
|
|
|
|
type = types.number;
|
|
|
|
default = 5;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-01-20 11:11:12 +00:00
|
|
|
packageUnwrapped = pkgs.static-nix-shell.mkBash {
|
2023-11-21 08:14:52 +00:00
|
|
|
pname = "sway-autoscaler";
|
2023-11-21 08:25:01 +00:00
|
|
|
pkgs = [ "jq" "sway" "util-linux" ];
|
2024-02-25 17:37:38 +00:00
|
|
|
srcRoot = ./.;
|
2023-11-21 08:14:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
services.sway-autoscaler = {
|
|
|
|
description = "adjust global desktop scale to match the activate application";
|
2024-03-21 16:02:06 +00:00
|
|
|
partOf = lib.mkIf cfg.config.autostart [ "graphical-session" ];
|
2024-03-21 15:05:23 +00:00
|
|
|
command = lib.escapeShellArgs [
|
2024-03-21 05:13:48 +00:00
|
|
|
"env"
|
|
|
|
"SWAY_DEFAULT_SCALE=${builtins.toString cfg.config.defaultScale}"
|
2024-03-21 05:23:38 +00:00
|
|
|
"sway-autoscaler"
|
2024-03-21 05:13:48 +00:00
|
|
|
"--loop-sec"
|
|
|
|
(builtins.toString cfg.config.interval)
|
|
|
|
];
|
2023-11-21 08:14:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|