Skip to content

Instantly share code, notes, and snippets.

@s1037989
Created March 30, 2025 16:17
Show Gist options
  • Save s1037989/b23e5584881c5565959643c9b1e26477 to your computer and use it in GitHub Desktop.
Save s1037989/b23e5584881c5565959643c9b1e26477 to your computer and use it in GitHub Desktop.

Media Sync

  • Auto Sync
    • When a hard drive is connected (one allowed by usbguard), run an application
    • Using an /etc config file, the UUID maps to what type of content to sync
    • rsync the type of content to the mount point of the hard drive
    • in the background, regularly check the progress of the transfer (du -sbc /dst | tail -1 | cut -f1) / (du -sbc /src | tail -1 | cut -f1) and write the percentage to /tmp/media/mount_point
      • if the size > 100, flip the division
      • if rsync is not running, empty /tmp/media/mount_point
      • if the media is not mounted, remove /tmp/media/mount_point
  • Kiosk
    • systemd start startx
    • systemd start xprogress
    • systemd start chromium --kiosk
    • run autologin startx on tty1 on boot
    • exec chromium-browser --kiosk
    • on x11 app exit, exit the tty and restart
    • can switch to another terminal to do a normal login
  • Setup
    • app.rpm
      • sig.rpm
    • kiosk.rpm
      • xorg.rpm
      • xprogress.rpm
      • chromium.rpm
      • startx systemd
      • xprogress systemd
      • chromium systemd
      • nic configuration

"Plan B"

  • while :; do if [ tty == 5 ]; then chvt 6; else chvt 6; fi; sleep 60; done
  • Progress Meter
    • $ ((i=0)); while :; do sleep .01; perl -E '$=sprintf "%.2f", ($ARGV[0]/$ARGV[1])*100; say "$%"; exit ($_<100)' $((i++)).$RANDOM 100 && break; done | zenity --progress --no-cancel --auto-close --text="Syncing to /media" --title="Busy"
    • $ while :; do sleep .01; perl -E 'exit 0 unless $ARGV[1]; $=sprintf "%.2f", ($ARGV[0]/$ARGV[1])*100; say "$%"; exit ($_<100)' "$(du -sbc /opt | tail -1 | cut -f1)" "$(du -sbc /opt | tail -1 | cut -f1)" && break; done | zenity --progress --no-cancel --auto-close --text="Syncing to /media" --title="Busy"
    • can root process run zenity on another xsession? or will user xinitrc need to run a background process that is always monitoring rsync?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment