askrobots / network-computer
Public
Your phone is the terminal. Stream a Linux/Mac desktop to an iPhone over WebRTC through NAT, with audio and input. Open source, single binaries.
Dan Quellhorst
Firefox policy: no WebRTC mDNS (a page using WebRTC made Firefox listen on UDP 5353)
a1d92f3
1 month, 3 weeks ago
History
nc-session-setup · 5.1 KB · 83 lines
| 1 | #!/bin/sh |
| 2 | # Per-session desktop settings, applied at every login (autostart) and by |
| 3 | # provisioning. Safe to run again. |
| 4 | [ "$(id -un)" = root ] && exec nc-as-user "$0" "$@" |
| 5 | q() { xfconf-query -c xfce4-keyboard-shortcuts "$@"; } |
| 6 | # Alt+Space: the search and launch bar; the window menu moves to Shift+Alt+Space |
| 7 | q -p '/xfwm4/custom/<Alt>space' -r 2>/dev/null |
| 8 | q -p '/xfwm4/custom/<Shift><Alt>space' -n -t string -s popup_menu_key 2>/dev/null || q -p '/xfwm4/custom/<Shift><Alt>space' -s popup_menu_key |
| 9 | q -p '/commands/custom/<Alt>space' -n -t string -s nc-launch 2>/dev/null || q -p '/commands/custom/<Alt>space' -s nc-launch |
| 10 | echo "shortcuts: Alt+Space search and launch; Shift+Alt+Space window menu" |
| 11 | |
| 12 | # an Object Server icon on the desktop, once (the user may delete it), marked |
| 13 | # trusted so Xfce opens it without the "untrusted launcher" question |
| 14 | D=$(xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME/Desktop"); L="$D/Object Server.desktop" |
| 15 | if [ -e "$L" ] && ! grep -q '^Exec=nc-object-open' "$L"; then rm -f "$L" "$HOME/.config/nc/object-icon-placed"; fi # an older version |
| 16 | if [ ! -e "$L" ] && [ ! -e "$HOME/.config/nc/object-icon-placed" ]; then |
| 17 | cp /usr/share/applications/nc-object-home.desktop "$L" && chmod +x "$L" && |
| 18 | gio set -t string "$L" metadata::xfce-exe-checksum "$(sha256sum "$L" | cut -d' ' -f1)" 2>/dev/null |
| 19 | mkdir -p "$HOME/.config/nc" && touch "$HOME/.config/nc/object-icon-placed" |
| 20 | fi |
| 21 | |
| 22 | # the dbbasic apps (nc-apps), Today and Radio on the desktop, so they are one double-click or |
| 23 | # double-tap away: each placed once and marked trusted (no "untrusted |
| 24 | # launcher" question); one you delete stays deleted; one installed later |
| 25 | # appears (nc-apps install runs this) |
| 26 | for f in /usr/share/applications/dbbasic-*.desktop /usr/share/applications/nc-today.desktop /usr/share/applications/nc-radio.desktop; do |
| 27 | [ -f "$f" ] || continue |
| 28 | # Today and Radio only while they are on (~/.config/nc/dashboard.env) |
| 29 | case $f in |
| 30 | */nc-today.desktop) grep -Eqi '^(WEATHER|NEWS)=(on|"on")?$' "$HOME/.config/nc/dashboard.env" 2>/dev/null || |
| 31 | [ ! -e "$HOME/.config/nc/dashboard.env" ] || continue ;; |
| 32 | */nc-radio.desktop) grep -Eqi '^RADIO=(off|no|false|0|"off")' "$HOME/.config/nc/dashboard.env" 2>/dev/null && continue ;; |
| 33 | esac |
| 34 | n=$(basename "$f" .desktop); mark="$HOME/.config/nc/placed-$n" |
| 35 | # a copy placed before the apps had launchers: bring its command up to date |
| 36 | if [ -e "$D/$n.desktop" ] && grep -q '^Exec=/desk/apps/' "$D/$n.desktop"; then |
| 37 | sed -i "s|^Exec=.*|$(grep '^Exec=' "$f")|" "$D/$n.desktop" |
| 38 | gio set -t string "$D/$n.desktop" metadata::xfce-exe-checksum "$(sha256sum "$D/$n.desktop" | cut -d' ' -f1)" 2>/dev/null |
| 39 | fi |
| 40 | [ -e "$mark" ] && continue |
| 41 | cp "$f" "$D/$n.desktop" && chmod +x "$D/$n.desktop" && |
| 42 | gio set -t string "$D/$n.desktop" metadata::xfce-exe-checksum "$(sha256sum "$D/$n.desktop" | cut -d' ' -f1)" 2>/dev/null |
| 43 | mkdir -p "$HOME/.config/nc" && touch "$mark" |
| 44 | done |
| 45 | |
| 46 | # ~/Objects (the object server's files, nc-object-files): in the file manager's |
| 47 | # side pane always, and on the desktop once, as a link the user may delete |
| 48 | O="$HOME/Objects"; B="$HOME/.config/gtk-3.0/bookmarks" |
| 49 | mkdir -p "$(dirname "$B")" |
| 50 | grep -qs "^file://$O " "$B" || echo "file://$O Objects" >> "$B" |
| 51 | if [ ! -e "$D/Objects" ] && [ ! -e "$HOME/.config/nc/objects-link-placed" ]; then |
| 52 | ln -s "$O" "$D/Objects" && mkdir -p "$HOME/.config/nc" && touch "$HOME/.config/nc/objects-link-placed" |
| 53 | fi |
| 54 | |
| 55 | # notifications bottom right: top right is where browser tabs and window buttons are |
| 56 | xfconf-query -c xfce4-notifyd -p /notify-location -n -t int -s 3 2>/dev/null || xfconf-query -c xfce4-notifyd -p /notify-location -s 3 |
| 57 | |
| 58 | # a plain background, once: it streams far cheaper than a detailed picture, and the |
| 59 | # dashboard sits on it (the user can pick any wallpaper afterwards) |
| 60 | if [ ! -e "$HOME/.config/nc/plain-background" ]; then |
| 61 | props=$(xfconf-query -c xfce4-desktop -l 2>/dev/null | grep '/workspace[0-9]*/image-style$') |
| 62 | if [ -z "$props" ]; then # a brand-new desktop has written none yet: name them from the screen |
| 63 | for mon in $(xrandr --listmonitors 2>/dev/null | awk 'NR>1{print $NF}'); do |
| 64 | for ws in 0 1 2 3; do props="$props /backdrop/screen0/monitor$mon/workspace$ws/image-style"; done |
| 65 | done |
| 66 | fi |
| 67 | set_ok="" |
| 68 | for p in $props; do |
| 69 | b=${p%image-style} |
| 70 | xfconf-query -c xfce4-desktop -p "${b}image-style" -n -t int -s 0 2>/dev/null || |
| 71 | xfconf-query -c xfce4-desktop -p "${b}image-style" -s 0 || continue # no image |
| 72 | xfconf-query -c xfce4-desktop -p "${b}color-style" -n -t int -s 0 2>/dev/null || |
| 73 | xfconf-query -c xfce4-desktop -p "${b}color-style" -s 0 # solid color |
| 74 | xfconf-query -c xfce4-desktop -p "${b}rgba1" -n -t double -s 0.075 -t double -s 0.09 \ |
| 75 | -t double -s 0.125 -t double -s 1 2>/dev/null || |
| 76 | xfconf-query -c xfce4-desktop -p "${b}rgba1" -t double -s 0.075 -t double -s 0.09 \ |
| 77 | -t double -s 0.125 -t double -s 1 |
| 78 | set_ok=1 |
| 79 | done |
| 80 | # done only once it worked: a first login may come before the desktop is ready |
| 81 | [ -z "$set_ok" ] || { mkdir -p "$HOME/.config/nc" && touch "$HOME/.config/nc/plain-background"; } |
| 82 | fi |
| 83 | pgrep -u "$(id -u)" -x conky >/dev/null || (setsid nc-dashboard >/dev/null 2>&1 &) |