Added clamshell mode
This commit is contained in:
parent
8213c61cbe
commit
7cc2c03a20
|
@ -1,3 +1,5 @@
|
||||||
{...}: {
|
{ ... }:
|
||||||
|
{
|
||||||
aa.isHeadless = false;
|
aa.isHeadless = false;
|
||||||
|
aa.windowManagers.sway.clamshell.enable = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,14 @@
|
||||||
lib,
|
lib,
|
||||||
namespace,
|
namespace,
|
||||||
...
|
...
|
||||||
}: let
|
}:
|
||||||
inherit (lib) mkEnableOption mkOption mkIf types;
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkEnableOption
|
||||||
|
mkOption
|
||||||
|
mkIf
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
cfg = config.${namespace}.windowManagers.sway;
|
cfg = config.${namespace}.windowManagers.sway;
|
||||||
nag = "swaynag";
|
nag = "swaynag";
|
||||||
|
@ -24,7 +30,18 @@
|
||||||
&& ${pkgs.sway-contrib.grimshot}/bin/grimshot --notify save ${target} \
|
&& ${pkgs.sway-contrib.grimshot}/bin/grimshot --notify save ${target} \
|
||||||
~/screenshots/"$(date -u --iso-8601=seconds)".png
|
~/screenshots/"$(date -u --iso-8601=seconds)".png
|
||||||
'';
|
'';
|
||||||
in {
|
|
||||||
|
clamshell_script = pkgs.writeShellScriptBin "clamshell" ''
|
||||||
|
read -r LS < ${cfg.clamshell.state_file}
|
||||||
|
|
||||||
|
case "$LS" in
|
||||||
|
*open) ${pkgs.sway}/bin/swaymsg output ${cfg.clamshell.output} enable ;;
|
||||||
|
*closed) ${pkgs.sway}/bin/swaymsg output ${cfg.clamshell.output} disable ;;
|
||||||
|
*) echo "Could not get lid state" >&2 ; exit 1 ;;
|
||||||
|
esac
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
options.${namespace}.windowManagers.sway = {
|
options.${namespace}.windowManagers.sway = {
|
||||||
enable = mkEnableOption "sway";
|
enable = mkEnableOption "sway";
|
||||||
|
|
||||||
|
@ -35,6 +52,32 @@ in {
|
||||||
Path to wallpaper, relative to xdg.dataHome
|
Path to wallpaper, relative to xdg.dataHome
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
clamshell = {
|
||||||
|
enable = mkEnableOption "clamshell mode";
|
||||||
|
output = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "eDP-1";
|
||||||
|
description = ''
|
||||||
|
The output that should be toggled on and off when the lid is closed
|
||||||
|
(applies only to laptops).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
state_file = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "/proc/acpi/button/lid/LID/state";
|
||||||
|
description = ''
|
||||||
|
The file containing lid state information. Assumes that file contents
|
||||||
|
look like:
|
||||||
|
|
||||||
|
state: closed
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
state: open
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -81,7 +124,10 @@ in {
|
||||||
# For screen sharing to work
|
# For screen sharing to work
|
||||||
xdg.portal = {
|
xdg.portal = {
|
||||||
enable = true;
|
enable = true;
|
||||||
extraPortals = with pkgs; [xdg-desktop-portal-wlr xdg-desktop-portal-gtk];
|
extraPortals = with pkgs; [
|
||||||
|
xdg-desktop-portal-wlr
|
||||||
|
xdg-desktop-portal-gtk
|
||||||
|
];
|
||||||
config.common.default = "*";
|
config.common.default = "*";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -97,10 +143,29 @@ in {
|
||||||
wrapperFeatures.gtk = true; # so that gtk works properly
|
wrapperFeatures.gtk = true; # so that gtk works properly
|
||||||
systemd.enable = true; # needed this for screen sharing to work
|
systemd.enable = true; # needed this for screen sharing to work
|
||||||
|
|
||||||
|
extraConfig = mkIf cfg.clamshell.enable ''
|
||||||
|
bindswitch --reload --locked lid:on output eDP-1 disable
|
||||||
|
bindswitch --reload --locked lid:off output eDP-1 enable
|
||||||
|
'';
|
||||||
config = {
|
config = {
|
||||||
inherit terminal menu left right up down modifier;
|
inherit
|
||||||
|
terminal
|
||||||
|
menu
|
||||||
|
left
|
||||||
|
right
|
||||||
|
up
|
||||||
|
down
|
||||||
|
modifier
|
||||||
|
;
|
||||||
workspaceAutoBackAndForth = true;
|
workspaceAutoBackAndForth = true;
|
||||||
|
|
||||||
|
startup = mkIf cfg.clamshell.enable [
|
||||||
|
{
|
||||||
|
command = "${clamshell_script}/bin/clamshell";
|
||||||
|
always = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
# Use catppuccin colors
|
# Use catppuccin colors
|
||||||
colors = {
|
colors = {
|
||||||
background = "$base";
|
background = "$base";
|
||||||
|
@ -146,7 +211,9 @@ in {
|
||||||
commands = [
|
commands = [
|
||||||
{
|
{
|
||||||
command = "inhibit_idle fullscreen";
|
command = "inhibit_idle fullscreen";
|
||||||
criteria = {class = ".*";};
|
criteria = {
|
||||||
|
class = ".*";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
@ -154,7 +221,7 @@ in {
|
||||||
focus.followMouse = false;
|
focus.followMouse = false;
|
||||||
|
|
||||||
fonts = {
|
fonts = {
|
||||||
names = ["Hack Nerd Font"];
|
names = [ "Hack Nerd Font" ];
|
||||||
size = 10.0;
|
size = 10.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue