From 2c0e580ba1c1cd28a135639bd8e17df14399db5c Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 3 Sep 2023 12:34:55 +0200 Subject: l super-vnc: init --- lass/5pkgs/super-vnc/default.nix | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lass/5pkgs/super-vnc/default.nix diff --git a/lass/5pkgs/super-vnc/default.nix b/lass/5pkgs/super-vnc/default.nix new file mode 100644 index 000000000..ce0e3aaa7 --- /dev/null +++ b/lass/5pkgs/super-vnc/default.nix @@ -0,0 +1,38 @@ +{ pkgs, lib }: let + + quoteChar = c: + if c == "\n" then "'\n'" + else c; + quote = x: if x == "" then "''" else lib.stringAsChars quoteChar x; + +in pkgs.writers.writeDashBin "super-vnc" '' + PATH=${lib.makeBinPath (with pkgs; [ + xorg.xrandr gnugrep coreutils xorg.xorgserver gnused openssh gawk tightvnc + ])} + remote=$1 + res_x=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1) + res_y=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2) + export modeline="$(gtf "$res_x" "$res_y" 60 | sed -n 's/.*Modeline "\([^" ]\+\)" \(.*\)/\1 \2/p')" + export name="$(echo "$modeline" | sed 's/\([^ ]\+\) .*/\1/')" + export vncline="''${res_x}x''${res_y}+0+0" + + if [ -z "$modeline" -o -z "$name" ]; then + echo "Error! modeline=$modeline name=$name" + exit 1 + fi + + echo $modeline + + # TODO user random highport + ssh "$remote" -L 5900:localhost:55900 bash <