From 00076e2abb4d89dc7cd76290b5433d53cd02ed79 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 19 Sep 2024 22:23:45 +0200 Subject: [PATCH] Run `rclone` user config script in Plasma --- scripts/Arch/Software/rclone/main.fish | 10 +++-- scripts/Common/Software/rclone/main.fish | 47 ++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/scripts/Arch/Software/rclone/main.fish b/scripts/Arch/Software/rclone/main.fish index 2eec2d34..9f138d65 100755 --- a/scripts/Arch/Software/rclone/main.fish +++ b/scripts/Arch/Software/rclone/main.fish @@ -1,16 +1,20 @@ #!/bin/env fish begin set -l dir (status dirname) + set -l base "$dir/../../../Common/Software/rclone/main.fish" source "$dir/../../Scripts/software.fish" - source "$dir/../../../Common/Software/rclone/main.fish" function installSW yayinst \ rclone end - function configureSW -V dir - fish "$dir/../../../Common/Software/rclone/main.fish" configure + function configureSW -V base + fish "$base" configure + end + + function userConfig -V base -a name + fish "$base" userConfig $argv end runInstaller $argv diff --git a/scripts/Common/Software/rclone/main.fish b/scripts/Common/Software/rclone/main.fish index 14c66d13..09d579a7 100755 --- a/scripts/Common/Software/rclone/main.fish +++ b/scripts/Common/Software/rclone/main.fish @@ -14,9 +14,32 @@ begin if [ (echo "$configs" | jq "length") -gt 0 ] if [ "$XDG_SESSION_TYPE" = "tty" ] + set -l sessionPid + set -l freeTty + set -l service + set -l sessionConfig + set -l welcomeConfig ~"$name"/.config/plasma-welcomerc set -l entryPoint ~"$name"/.config/autostart/PortValhallaProfile.desktop sudo -u "$name" mkdir -p "$(dirname "$entryPoint")" + begin + set -l file (sudo mktemp) + sudo openvt -sw -- bash -c "tty > $(string escape $file)" + set freeTty (basename (sudo cat $file)) + sudo rm $file + end + + set service "getty@$freeTty" + set sessionConfig "/etc/systemd/system/$service.service.d/autologin.conf" + sudo mkdir -p (dirname $sessionConfig) + + begin + printf %s\n \ + "[General]" \ + "LastSeenVersion=1.0.0" \ + "ShowUpdatePage=false" + end | sudo -u "$name" tee "$welcomeConfig" > /dev/null + begin printf %s\n \ "#!/user/bin/env xdg-open" \ @@ -32,9 +55,27 @@ begin end | sudo -u "$name" tee "$entryPoint" > /dev/null sudo chmod +x "$entryPoint" - sudo -Eu "$name" dbus-launch --exit-with-session startplasma-wayland &> /dev/null - rm "$entryPoint" - rm ~"$name"/.config/plasma-welcomerc + + begin + printf %s\n \ + "[Service]" \ + "ExecStart=" \ + "ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin $name %I \$TERM" + end | sudo tee "$sessionConfig" > /dev/null + + sudo systemctl daemon-reload + sudo systemctl restart $service + + while [ -z "$sessionPid" ] + set sessionPid (sudo pgrep -t $freeTty -u "$name") + end + + sudo openvt -sw -- sudo -u "$name" env (sudo cat /proc/$sessionPid/environ | string split0) /usr/lib/plasma-dbus-run-session-if-needed startplasma-wayland + sudo rm "$entryPoint" + sudo rm "$welcomeConfig" + sudo rm "$sessionConfig" + sudo rmdir (dirname "$sessionConfig") + sudo systemctl daemon-reload else if [ -n "$name" ] && [ "$name" != "$USER" ] sudo -Eu "$name" CONFIG_NAME="$CONFIG_NAME" fish "$(status filename)" userConfig else