diff --git a/modules/sway/config/config.d/custom-keybindings.conf b/modules/sway/config/config.d/custom-keybindings.conf index 5faddece..4a00bd77 100644 --- a/modules/sway/config/config.d/custom-keybindings.conf +++ b/modules/sway/config/config.d/custom-keybindings.conf @@ -47,3 +47,9 @@ mode "$mode_system" { bindsym Return mode "default" bindsym Escape mode "default" } + +set $mode_vncclient In VNCClient mode. Press $mod+Num_Lock to return. +bindsym $mod+Num_Lock mode "$mode_vncclient" +mode "$mode_vncclient" { + bindsym $mod+Num_Lock mode "default" +} diff --git a/modules/sway/config/wayvnc/config.nix b/modules/sway/config/wayvnc/config.nix new file mode 100644 index 00000000..1ecc2e5f --- /dev/null +++ b/modules/sway/config/wayvnc/config.nix @@ -0,0 +1,8 @@ +{ psCfg, pkgs }: " +address=0.0.0.0 +enable_auth=true +username=${psCfg.user.name} +password=${psCfg.user.password} +private_key_file=/run/secrets/vnc-key.pem +certificate_file=/run/secrets/vnc-cert.pem +" diff --git a/modules/sway/default.nix b/modules/sway/default.nix index cfc5733c..568bcb41 100644 --- a/modules/sway/default.nix +++ b/modules/sway/default.nix @@ -7,11 +7,13 @@ in { options.pub-solar.sway = { enable = mkEnableOption "Life in boxes"; - }; - options.pub-solar.sway.v4l2loopback.enable = mkOption { - type = types.bool; - default = true; - description = "WebCam streaming tool"; + vnc.enable = mkEnableOption "Enable vnc service"; + + v4l2loopback.enable = mkOption { + type = types.bool; + default = true; + description = "WebCam streaming tool"; + }; }; config = mkIf cfg.enable (mkMerge [ @@ -76,6 +78,8 @@ in systemd.user.services.waybar = import ./waybar.service.nix pkgs; systemd.user.targets.sway-session = import ./sway-session.target.nix pkgs; + systemd.user.services.wayvnc = mkIf cfg.vnc.enable (import ./wayvnc.service.nix pkgs); + xdg.configFile."sway/config".source = ./config/config; xdg.configFile."sway/config.d/colorscheme.conf".source = ./config/config.d/colorscheme.conf; xdg.configFile."sway/config.d/theme.conf".source = ./config/config.d/theme.conf; @@ -83,6 +87,7 @@ in xdg.configFile."sway/config.d/custom-keybindings.conf".source = ./config/config.d/custom-keybindings.conf; xdg.configFile."sway/config.d/applications.conf".source = ./config/config.d/applications.conf; xdg.configFile."sway/config.d/systemd.conf".source = ./config/config.d/systemd.conf; + xdg.configFile."wayvnc/config".text = import ./config/wayvnc/config.nix { inherit psCfg; inherit pkgs; }; }; }) ]); diff --git a/modules/sway/wayvnc.service.nix b/modules/sway/wayvnc.service.nix new file mode 100644 index 00000000..0963da5e --- /dev/null +++ b/modules/sway/wayvnc.service.nix @@ -0,0 +1,19 @@ +pkgs: +{ + Unit = { + Description = "A VNC server for wlroots based Wayland compositors "; + Documentation = "https://github.com/any1/wayvnc"; + BindsTo = [ "sway-session.target" ]; + After = [ "graphical-session-pre.target" "network-online.target" ]; + Wants = [ "graphical-session-pre.target" "network-online.target" ]; + }; + + Service = { + Type = "simple"; + ExecStart = "${pkgs.wayvnc}/bin/wayvnc"; + }; + + Install = { + WantedBy = [ "sway-session.target" ]; + }; +}