From d7a7571b00f280c456c959636855f2463f0ee8a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Schwarz=C3=A4ugl?= Date: Sat, 22 Mar 2025 23:11:50 +0100 Subject: [PATCH] fix: properly run screenshare as user and service --- SwarselSystems.org | 48 ++++++++++++++++++++++++++---- pkgs/fullscreen/default.nix | 10 +++++++ profiles/nixos/common/packages.nix | 1 + profiles/nixos/optional/work.nix | 2 +- scripts/screenshare.sh | 25 +++++++++++++--- 5 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 pkgs/fullscreen/default.nix diff --git a/SwarselSystems.org b/SwarselSystems.org index 3bc6df9..a93849e 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -2624,6 +2624,25 @@ This utility checks if there are updated packages in nixpkgs-unstable. It does s } #+end_src +**** fullscreen +:PROPERTIES: +:CUSTOM_ID: h:9d49531a-1d9b-4600-b200-18befb5e0f3a +:END: + +This application moves the wl-mirror app to the T workspace and makes it fullscreen there. + +#+begin_src nix :tangle pkgs/fullscreen/default.nix + { name, writeShellApplication, sway, ... }: + + writeShellApplication { + inherit name; + runtimeInputs = [ sway ]; + text = '' + swaymsg '[app_id=at.yrlf.wl_mirror] move to workspace 14:T' + swaymsg '[app_id=at.yrlf.wl_mirror] fullscreen' + ''; + } +#+end_src **** screenshare :PROPERTIES: :CUSTOM_ID: h:960e539c-2a5a-4e21-b3d4-bcdfc8be8fda @@ -2631,12 +2650,30 @@ This utility checks if there are updated packages in nixpkgs-unstable. It does s #+begin_src shell :tangle scripts/screenshare.sh + + headless="false" + while [[ $# -gt 0 ]]; do + case "$1" in + -h) + headless="true" + ;; + ,*) + echo "Invalid option detected." + ;; + esac + shift + done + SHARESCREEN="$(nix eval --raw ~/.dotfiles#nixosConfigurations."$(hostname)".config.home-manager.users."$(whoami)".swarselsystems.sharescreen)" - wl-mirror "$SHARESCREEN" & - sleep 0.1 - swaymsg '[app_id=at.yrlf.wl_mirror] move to workspace 14:T' - swaymsg '[app_id=at.yrlf.wl_mirror] fullscreen' + if [[ $headless == "true" ]]; then + wl-mirror "$SHARESCREEN" + else + wl-mirror "$SHARESCREEN" & + sleep 0.1 + swaymsg '[app_id=at.yrlf.wl_mirror] move to workspace 14:T' + swaymsg '[app_id=at.yrlf.wl_mirror] fullscreen' + fi #+end_src @@ -4843,6 +4880,7 @@ Mostly used to install some compilers and lsp's that I want to have available wh just screenshare + fullscreen # keyboards qmk @@ -8391,7 +8429,7 @@ Options that I need specifically at work. There are more options at [[#h:f0b2ea9 enable = true; description = "Screensharing service upon dongle plugin"; serviceConfig = { - ExecStart = "${pkgs.screenshare}/bin/screenshare"; + ExecStart = "${pkgs.screenshare}/bin/screenshare -h"; User = mainUser; Group = "users"; Environment = [ diff --git a/pkgs/fullscreen/default.nix b/pkgs/fullscreen/default.nix new file mode 100644 index 0000000..ca6080c --- /dev/null +++ b/pkgs/fullscreen/default.nix @@ -0,0 +1,10 @@ +{ name, writeShellApplication, sway, ... }: + +writeShellApplication { + inherit name; + runtimeInputs = [ sway ]; + text = '' + swaymsg '[app_id=at.yrlf.wl_mirror] move to workspace 14:T' + swaymsg '[app_id=at.yrlf.wl_mirror] fullscreen' + ''; +} diff --git a/profiles/nixos/common/packages.nix b/profiles/nixos/common/packages.nix index 90c41ed..438f3ea 100644 --- a/profiles/nixos/common/packages.nix +++ b/profiles/nixos/common/packages.nix @@ -47,6 +47,7 @@ just screenshare + fullscreen # keyboards qmk diff --git a/profiles/nixos/optional/work.nix b/profiles/nixos/optional/work.nix index b83f67b..1838c6d 100644 --- a/profiles/nixos/optional/work.nix +++ b/profiles/nixos/optional/work.nix @@ -122,7 +122,7 @@ in enable = true; description = "Screensharing service upon dongle plugin"; serviceConfig = { - ExecStart = "${pkgs.screenshare}/bin/screenshare"; + ExecStart = "${pkgs.screenshare}/bin/screenshare -h"; User = mainUser; Group = "users"; Environment = [ diff --git a/scripts/screenshare.sh b/scripts/screenshare.sh index 689d11b..e4d4f5f 100644 --- a/scripts/screenshare.sh +++ b/scripts/screenshare.sh @@ -1,6 +1,23 @@ +headless="false" +while [[ $# -gt 0 ]]; do + case "$1" in + -h) + headless="true" + ;; + *) + echo "Invalid option detected." + ;; + esac + shift +done + SHARESCREEN="$(nix eval --raw ~/.dotfiles#nixosConfigurations."$(hostname)".config.home-manager.users."$(whoami)".swarselsystems.sharescreen)" -wl-mirror "$SHARESCREEN" & -sleep 0.1 -swaymsg '[app_id=at.yrlf.wl_mirror] move to workspace 14:T' -swaymsg '[app_id=at.yrlf.wl_mirror] fullscreen' +if [[ $headless == "true" ]]; then + wl-mirror "$SHARESCREEN" +else + wl-mirror "$SHARESCREEN" & + sleep 0.1 + swaymsg '[app_id=at.yrlf.wl_mirror] move to workspace 14:T' + swaymsg '[app_id=at.yrlf.wl_mirror] fullscreen' +fi