2021-12-28 02:54:26 -06:00
|
|
|
#!/bin/sh
|
2021-11-27 19:30:34 -06:00
|
|
|
|
2022-01-02 22:35:07 -06:00
|
|
|
# For syncing some files with OneDrive
|
|
|
|
# Assumes that the sync target is set up as OneDrive:Syncs in rclone
|
|
|
|
|
2021-11-27 19:30:34 -06:00
|
|
|
if [ $(id -u) -eq 0 ]; then
|
2022-01-13 12:04:50 -06:00
|
|
|
exec sudo -H -u sintan $0 "$@"
|
2021-11-27 19:30:34 -06:00
|
|
|
fi
|
|
|
|
|
2022-01-08 18:24:52 -06:00
|
|
|
notify() {
|
2021-11-27 19:30:34 -06:00
|
|
|
#Detect the name of the display in use
|
|
|
|
local display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)"
|
|
|
|
|
|
|
|
#Detect the user using such display
|
|
|
|
local user=$(who | grep '('$display')' | awk '{print $1}' | head -n 1)
|
|
|
|
|
|
|
|
#Detect the id of the user
|
|
|
|
local uid=$(id -u $user)
|
|
|
|
|
|
|
|
sudo -u $user DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus notify-send -a rclone -h string:desktop-entry:alacritty "$@"
|
|
|
|
}
|
|
|
|
|
2022-01-08 18:24:52 -06:00
|
|
|
notify "OneDrive sync" "Sync started..."
|
2022-07-14 14:52:14 -05:00
|
|
|
flock -n /tmp/onedrivesync.lock rclone sync -c -L --log-file="/home/sintan/TempStorage/OneDriveSync.log" --log-level INFO "/home/sintan/TempStorage/OneDrive/" OneDrive:Syncs
|
2022-01-08 18:24:52 -06:00
|
|
|
notify "OneDrive sync" "Sync finished!"
|
|
|
|
|