=== removed file 'bin/xsession-cmd' --- old/bin/xsession-cmd 2024-04-17 00:59:47 +0000 +++ new/bin/xsession-cmd 1970-01-01 00:00:00 +0000 @@ -1,62 +0,0 @@ -#!/bin/zsh -setopt no_unset extended_glob warn_create_global -set -x - -# helpers -die() { - printf >&2 '%s\n' "$@" - exit 1 -} - -ensure-container-started() { - [[ $1 == */* ]] && die "Invalid container name: ${(qqq)1}" - s6-svc -wU -T 4000 -o /run/service/container.$1 -} - -cmd_up() { - local name - for name in "$@"; do - ensure-container-started $name - done -} - -cmd_down() { - local name - for name in "$@"; do - [[ $name == */* ]] && die "Invalid container name: ${(qqq)name}" - s6-svc -wd -T 1000 -d /run/service/container.$name || \ - s6-svc -wd -T 1000 -dk /run/service/container.$name - done -} - -cmd_link() { - local old new relpath - - [[ $1 == */* ]] && die "Invalid container name: ${(qqq)1}" - old=$1 - - [[ $2 == */* ]] && die "Invalid container name: ${(qqq)2}" - new=$2 - - shift 2 || exit $? - for relpath in "$@"; do - [[ $relpath == /* ]] && die "Invalid relpath: ${(qqq)relpath}" - [[ $PWD/$relpath != ${relpath:a} ]] && die "Invalid relpath: ${(qqq)relpath}" - done - ensure-container-started $old - ensure-container-started $new - link-to-container-inbox $old $new "$@" || exit $? -} - - -main() { - [[ $# -gt 0 ]] || die "xsession-cmd: argument required" - local cmd=$1 - shift - case $cmd in - (up|down|link) cmd_$cmd "$@" || die "command failed: ${(qqq)cmd}";; - (*) die "unknown command: ${(qqq)cmd}" - esac -} - -main "$@" === modified file 'home/container-setup' --- old/home/container-setup 2024-04-17 00:59:47 +0000 +++ new/home/container-setup 2024-04-11 16:14:41 +0000 @@ -23,18 +23,6 @@ link-to-container-inbox $from_container $CONTAINER_NAME.$USER "$@" || exit $? } -# Copy over the versioned filesystem image -copy-skel() { - local skel dst - [[ -d $REPO_ROOT/$1 ]] || die "skel dir $REPO_ROOT/$1 does not exist" - s6-hiercopy $REPO_ROOT/$1/homedir $DSTROOT/home/$USER || exit $? - for skel in $REPO_ROOT/$1/*/*(DN); do - [[ ${skel:h:t} == homedir ]] && continue - dst=$DSTROOT/${skel:h:t}/${skel:t} - s6-hiercopy $skel $dst || exit $? - done -} - setup-sndio() { local sndio_container=sndiod.$USER local sndio_dir=$DSTROOT/run/inbox/$sndio_container/sndio-$UID @@ -78,9 +66,6 @@ setup-urxvt case $CONTAINER_NAME in - (xpra) - copy-skel xpra-skel - ;; (ssh|rcm-ssh) setup-gpg-ssh-agent ;; === modified file 'home/xsession-setup' --- old/home/xsession-setup 2024-04-17 00:59:47 +0000 +++ new/home/xsession-setup 2024-04-14 15:35:09 +0000 @@ -7,11 +7,6 @@ REPO_ROOT=${0:P:h:h} # helpers -die() { - printf >&2 '%s\n' "$@" - exit 1 -} - ensure-container-started() { [[ $1 == */* ]] && die "Invalid container name: ${(qqq)1}" s6-svc -wU -T 4000 -o /run/service/container.$1 === removed directory 'xpra-skel' === removed directory 'xpra-skel/homedir' === removed directory 'xpra-skel/homedir/.config' === removed file 'xpra-skel/homedir/.config/ccx.xmodmap' --- old/xpra-skel/homedir/.config/ccx.xmodmap 2024-04-17 00:59:47 +0000 +++ new/xpra-skel/homedir/.config/ccx.xmodmap 1970-01-01 00:00:00 +0000 @@ -1,84 +0,0 @@ -! xmodmap for the dead keys stolen from Colemak layout. - -clear lock -add lock = XF86Calculator -add lock = Menu - -!! left ctrl as compose key -!keysym Control_L = Multi_key Multi_key -!keycode 37 = Multi_key Multi_key - -!keysym Control_L = Mode_switch Mode_switch -keycode 37 = Mode_switch Mode_switch - -!! right win key as second modifier -!keysym Super_R = Mode_switch Mode_switch - -!! the split shift key -!keycode 94 = Shift_L Shift_L Shift_L Shift_L -keycode 94 = Shift_L ISO_Prev_Group Shift_L ISO_Prev_Group -!add shift = Shift_L - -!! menu key -!keysym Menu = backslash bar grave asciitilde - -keysym Up = Up NoSymbol uparrow intersection -keysym Left = Left NoSymbol leftarrow ifonlyif -keysym Right = Right NoSymbol rightarrow implies -keysym Down = Down NoSymbol downarrow union - -keycode 49 = grave asciitilde dead_tilde trademark -keycode 10 = 1 exclam exclamdown onesuperior -keycode 11 = 2 at masculine twosuperior -keycode 12 = 3 numbersign ordfeminine threesuperior -keycode 13 = 4 dollar cent sterling -keycode 14 = 5 percent EuroSign yen -keycode 15 = 6 asciicircum hstroke Hstroke -keycode 16 = 7 ampersand eth ETH -keycode 17 = 8 asterisk thorn THORN -keycode 18 = 9 parenleft leftsinglequotemark leftdoublequotemark -keycode 19 = 0 parenright rightsinglequotemark rightdoublequotemark -keycode 20 = minus underscore endash emdash -keycode 21 = equal plus multiply division -keycode 51 = backslash bar notequal approximate - -keycode 24 = q Q adiaeresis Adiaeresis -keycode 25 = w W ecaron Ecaron -keycode 26 = e E eacute Eacute -keycode 27 = r R rcaron Rcaron -keycode 28 = t T dead_acute dead_doubleacute -!keycode 29 = y Y udiaeresis Udiaeresis -keycode 29 = y Y yacute Yacute -keycode 30 = u U uacute Uacute -keycode 31 = i I iacute Iacute -keycode 32 = o O oacute Oacute -keycode 33 = p P oslash Ooblique -keycode 34 = bracketleft braceleft bracketleft U2200 -keycode 35 = bracketright braceright bracketright U2203 -!keycode 36 = Return NoSymbol Return -!keycode 37 = Control_L NoSymbol Control_L - -keycode 38 = a A aacute Aacute -keycode 39 = s S scaron Scaron -keycode 40 = d D dead_diaeresis degree -keycode 41 = f F atilde Atilde -keycode 42 = g G dead_ogonek infinity -keycode 43 = h H dead_caron copyright -keycode 44 = j J dstroke Dstroke -keycode 45 = k K dead_abovering asciitilde -keycode 46 = l L lstroke Lstroke -!keycode 47 = semicolon colon odiaeresis Odiaeresis -keycode 47 = semicolon colon uring Uring -keycode 48 = apostrophe quotedbl grave doublelowquotemark -!keycode 48 = apostrophe quotedbl ssharp registered - -keycode 52 = z Z zcaron Zcaron -keycode 53 = x X dead_circumflex asciitilde -keycode 54 = c C ccaron Ccaron -keycode 55 = v V dead_grave registered -keycode 56 = b B dead_breve asciitilde -keycode 57 = n N ncaron Ncaron -keycode 58 = m M dead_macron mu -keycode 59 = comma less dead_cedilla lessthanequal -keycode 60 = period greater dead_abovedot greaterthanequal -keycode 61 = slash question questiondown asciitilde === removed directory 'xpra-skel/homedir/bin' === removed file 'xpra-skel/homedir/bin/xkb' --- old/xpra-skel/homedir/bin/xkb 2024-04-17 00:59:47 +0000 +++ new/xpra-skel/homedir/bin/xkb 1970-01-01 00:00:00 +0000 @@ -1,10 +0,0 @@ -#!/bin/sh -setxkbmap \ - -model thinkpad \ - -option terminate:ctrl_alt_bksp \ - -option caps:ctrl_modifier \ - -option compose:ralt \ - -option grp:shift_toggle \ - -option grp_led:scroll \ - us,cz ,qwerty -xmodmap ~/.config/ccx.xmodmap === modified file 'xsession-skel/homedir/bin/ptmx-handler' --- old/xsession-skel/homedir/bin/ptmx-handler 2024-04-17 00:59:47 +0000 +++ new/xsession-skel/homedir/bin/ptmx-handler 2024-04-14 15:35:09 +0000 @@ -9,5 +9,5 @@ fdmove 1 4 # copy to stdout fdmove 3 0 # move ptmx to FD 3 redirfd -r 0 /dev/null # open /dev/null for stdin -importas -D unnamed NAME 1 # get first positional argument, falling back to "unnamed" +importas -D unnamed 1 NAME # get first positional argument, falling back to "unnamed" background { urxvt -name $NAME -pty-fd 3 } === removed file 'xsession-skel/homedir/bin/run-in-container-xpra' --- old/xsession-skel/homedir/bin/run-in-container-xpra 2024-04-17 00:59:47 +0000 +++ new/xsession-skel/homedir/bin/run-in-container-xpra 1970-01-01 00:00:00 +0000 @@ -1,26 +0,0 @@ -#!/bin/zsh -# vim: sts=2 sw=2 et -setopt no_unset warn_create_global - -main() { - local container display xsession_cookie - container=$1 - shift || exit 100 - [[ $container == */* ]] && exit 100 - display=${DISPLAY#:} - xsession_cookie=${"$(xauth list $DISPLAY)"##* } || exit $? - - # s6-sudo /run/cmd.s up $container || exit $? - s6-sudo /run/cmd.s link $container xsession.$display.$USER run/exec/x11 run/exec/exec || exit $? - s6-sudo /run/cmd.s link xsession.$display.$USER xpra.$USER tmp/.X11-unix/X$display || exit $? - - local -a xpra - xpra=( $(s6-sudo /run/inbox/xpra.ccx/run/exec/x11 $display $xsession_cookie run-in-container-xpra recombee-browser.ccx) ) - (($#xpra == 2)) || exit 1 - - s6-sudo /run/cmd.s link xpra.$USER $container tmp/.X11-unix/X$xpra[1] || exit $? - exec s6-sudo /run/inbox/$container/run/exec/x11 "$xpra[@]" "$@" -} -typeset -f -t main - -main "$@" === renamed file 'xpra-skel/homedir/bin/run-in-container-xpra' => 'xsession-skel/homedir/bin/run-in-container-xpra' --- old/xpra-skel/homedir/bin/run-in-container-xpra 2024-04-17 00:59:47 +0000 +++ new/xsession-skel/homedir/bin/run-in-container-xpra 2022-02-18 14:03:27 +0000 @@ -1,141 +1,95 @@ #!/bin/zsh -# vim: sts=2 sw=2 et -setopt no_unset warn_create_global +setopt no_unset zmodload zsh/system -typeset -g map=/run/display-container-map -typeset -g scandir=/run/service -typeset -g build=/run/tmp/service - -main() { - typeset -g container client_display - container=$1 - shift || exit 100 - [[ $container == */* ]] && exit 100 - - client_display=${${DISPLAY%%.*}#:} - do_lock - find_server_display - ensure_services - do_unlock - start_services - print_cookie -} -typeset -f -t main - -do_lock() { - mkdir -p $map || exit $? - touch $map/.lock || exit $? - zsystem flock -f lockfd $map/.lock || exit $? -} - -find_server_display() { - typeset -g display - local -a found allocated - found=( $map/*=$container(N) ) - - if ! (($#found)); then - # spawn a new Xpra session this container. - allocated=( $map/*=*(N) ) - allocated=( ${${allocated:t}%%=*} ) - #for n in {${${DISPLAY%%.*}#:}00..${${DISPLAY%%.*}#:}99}; do - for n in {100..199}; do - if (( $allocated[(I)$n] == 0 )); then - display=$n - touch $map/$display=$container - break - fi - done - if [[ -z $display ]]; then - exit 3 # All 99 displays occupied?! +container=$1 +shift || exit 100 +[[ $container == */* ]] && exit 100 + +display='' +#$(( ${${DISPLAY#}%%.*} * 100 )) +#(( $display > 0 )) || exit 111 + +map=/run/display-container-map +mkdir -p $map || exit $? +touch $map/.lock || exit $? +zsystem flock -f lockfd $map/.lock || exit $? + +running=( $map/*=$container(N) ) + +if ! (($#running)); then + # spawn a new Xpra session this container. + all=( $map/*=*(N) ) + all=( ${${all:t}%%=*} ) + for n in {${${DISPLAY%%.*}#:}00..${${DISPLAY%%.*}#:}99}; do + if (( $all[(I)$n] == 0 )); then + display=$n + touch $map/$display=$container + break fi - else - display=${${found[1]:t}%%=*} - fi -} - -ensure_services() { - typeset -g signal_svscan=0 - typeset -g sv_name_xorg=xpra-xorg.$display - typeset -g sv_name_server=xpra-server.$display - typeset -g sv_name_client=xpra-client.$display.for.$client_display - check_sv_xorg - check_sv_server - check_sv_client - if ((signal_svscan)); then - s6-svscanctl -a /run/service || exit $? - fi -} - - + done + if [[ -z $display ]]; then + exit 2 # All 99 displays occupier?! + fi +else + display=${${running[1]:t}%%=*} +fi + +signal_svscan=0 + +typeset -gA svc_extra mksvcdir(){ local name tmpsv f data name=$1 - shift || exit $? - mkdir -p $build || exit $? - tmpsv=$build/$name + shift + mkdir -p /run/tmp/service || exit $? + tmpsv=/run/tmp/service/$name mkdir $tmpsv || exit $? touch $tmpsv/run || exit $? printf '%s\n' "$@" >$tmpsv/run || exit $? chmod +x $tmpsv/run || exit $? - mv $tmpsv $scandir/ || exit $? + svc_extra=( ) + mv $tmpsv /run/service/ || exit $? (( signal_svscan++ )) return 0 } -check_sv_xorg() { - local sv=$scandir/$sv_name_xorg - [[ -d $sv ]] && return - - local tmpsv=$build/$sv_name_xorg - mkdir -p $tmpsv/{env,data} || exit $? - touch $tmpsv/down || exit $? - echo 3 >$tmpsv/notification-fd || exit $? - ln -s -f ${commands[service.xpra-xorg.run]} $tmpsv/run || exit $? - mv $tmpsv $scandir/ || exit $? +if ! [[ -d /run/service/xpra-xorg.$display ]]; then + mkdir -p /run/service/xpra-xorg.$display/{env,data} || exit $? + touch /run/service/xpra-xorg.$display/down || exit $? + echo 3 >/run/service/xpra-xorg.$display/notification-fd || exit $? + ln -s -f ${commands[service.xpra-xorg.run]} /run/service/xpra-xorg.$display/run || exit $? (( signal_svscan++ )) -} - -check_sv_server() { - local sv=$scandir/$sv_name_server - [[ -d $sv ]] && return - - mksvcdir $sv:t \ +fi + +if ! [[ -d /run/service/xpra-server.$display ]]; then + mksvcdir xpra-server.$display \ '#!/bin/execlineb -P' \ xpra-server $display --displayfd=3 - echo 3 >$sv/notification-fd || exit $? -} - -check_sv_client() { - local sv=$scandir/$sv_name_client - [[ -d $sv ]] && return - - mksvcdir $sv:t \ + echo 3 >/run/service/xpra-server.$display/notification-fd || exit $? +fi + +if ! [[ -d /run/service/xpra-client.$display ]]; then + mksvcdir xpra-client.$display \ '#!/bin/execlineb -P' \ - 's6-envdir env' \ xpra-client "$display" \ "--title=\"[${container}:${display}] @title@ wid:@windowid@\"" - mkdir -p $sv/env || exit $? - printf '%s\n' $DISPLAY >$sv/env/DISPLAY -} - -do_unlock() { - zsystem flock -u $lockfd - unset lockfd -} - -start_services() { - s6-svc -wU -T 5000 -o $scandir/$sv_name_server || exit $? - s6-svc -o $scandir/$sv_name_client || exit $? -} - -print_cookie() { - local -a cookies - # Obtain authentication cookie - cookies=( $(xauth -f /run/Xauthority.$display list :$display ) ) - (( $#cookies == 3 )) || exit 1 - [[ $cookies[2] == MIT-MAGIC-COOKIE-1 ]] || exit 1 - printf '%s\t%s\n' $display $cookies[3] -} - -main "$@" +fi + +if ((signal_svscan)); then + s6-svscanctl -a /run/service || exit $? +fi + +zsystem flock -u $lockfd + +s6-svc -wU -T 5000 -o /run/service/xpra-server.$display || exit $? +s6-svc -o /run/service/xpra-client.$display || exit $? + +# Obtain authentication cookie +cookies=( $(xauth -f /run/Xauthority.$display list :$display ) ) +(( $#cookies == 3 )) || exit 1 +[[ $cookies[2] == MIT-MAGIC-COOKIE-1 ]] || exit 1 +cookie=$cookies[3] + + +powerbox-plumb "x11/$container/$display/$cookie/$( for arg in "$@"; do s6-quote -- "$arg"; done )" === renamed file 'xpra-skel/homedir/bin/service.xpra-xorg.run' => 'xsession-skel/homedir/bin/service.xpra-xorg.run' --- old/xpra-skel/homedir/bin/service.xpra-xorg.run 2024-04-17 00:59:47 +0000 +++ new/xsession-skel/homedir/bin/service.xpra-xorg.run 2021-01-20 13:55:49 +0000 @@ -8,7 +8,7 @@ importas -i HOME HOME importas -D /run/user/$UID XDG_RUNTIME_DIR XDG_RUNTIME_DIR } -Xorg +/usr/libexec/Xorg -displayfd 3 -noreset -novtswitch === renamed file 'xpra-skel/homedir/bin/xpra-client' => 'xsession-skel/homedir/bin/xpra-client' === renamed file 'xpra-skel/homedir/bin/xpra-launch-xorg' => 'xsession-skel/homedir/bin/xpra-launch-xorg' === renamed file 'xpra-skel/homedir/bin/xpra-server' => 'xsession-skel/homedir/bin/xpra-server' --- old/xpra-skel/homedir/bin/xpra-server 2024-04-17 00:59:47 +0000 +++ new/xsession-skel/homedir/bin/xpra-server 2023-01-10 19:16:35 +0000 @@ -5,7 +5,7 @@ export XAUTHORITY=/run/Xauthority.$xpra_display truncate -s 0 $XAUTHORITY || exit $? -{ printf "add :%d . " $1; busybox xxd -p -l 16 'xsession-skel/homedir/xpra.xorg.conf'