PortValhalla/scripts/Common/Software/rclone/main.fish

47 lines
1.8 KiB
Fish
Raw Normal View History

#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../Scripts/software.fish"
function configureSW -V dir
sudo cp "$dir/rclone.service" "$dir/rclone.target" "$dir/rclone@.service" /etc/systemd/user
end
function userConfig -V dir -a name
source "$dir/../../Scripts/config.fish"
set -l key "valhalla.users.$name.rclone.configurations"
2024-07-20 03:09:13 +00:00
set -l configs (getConfig "$key" --apply "builtins.attrNames" --json)
if [ (echo "$configs" | jq "length") -gt 0 ]
if [ "$XDG_SESSION_TYPE" = "tty" ]
set -l entryPoint ~"$name"/.config/autostart/PortValhallaProfile.desktop
2024-07-20 03:09:42 +00:00
sudo -u "$name" mkdir -p "$(dirname "$entryPoint")"
begin
printf %s\n \
"#!/user/bin/env xdg-open" \
"[Desktop Entry]" \
"Name=PortValhalla Profile" \
"Type=Application" \
"Terminal=false" (
printf "%s " \
"Exec=env" \
"CONFIG_MODULE=$(echo "$CONFIG_MODULE" | string escape)" \
"konsole -e fish $(realpath (status filename) | string escape) userConfig"
)
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
else
echo "Please complete the setup of your rclone configurations!"
rclone config || true
end
end
end
runInstaller $argv
end