aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rwxr-xr-xconfig/x11/xinitrc8
-rwxr-xr-xlocal/bin/clout60
3 files changed, 53 insertions, 19 deletions
diff --git a/README.md b/README.md
index 01169da..3cc764e 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,3 @@ $ ./install
| mpv | https://mpv.io/ | Simple video player |
| moc | https://moc.daper.net/ | Music player |
| redshift | http://jonls.dk/redshift/ | Change screen color temperature |
-
-## School 19 Config
-
-Configuration for school 19 can be found on the [s19](https://github.com/HappyTramp/dotfiles/tree/s19) branch.
diff --git a/config/x11/xinitrc b/config/x11/xinitrc
index dfe9ab6..41c1e93 100755
--- a/config/x11/xinitrc
+++ b/config/x11/xinitrc
@@ -1,13 +1,15 @@
#!/bin/sh
-keynav daemonize # moving the cursor around without the mouse
-redshift & # filter blue light
-dunst & # notification daemon
# certain event cause rate to reset (https://wiki.archlinux.org/title/Xorg/Keyboard_configuration)
# -ardelay milliseconds
# -arinterval milliseconds
xset r rate 200 50 # delay before keyrepeat and keyrepeat rate
+
+keynav daemonize # moving the cursor around without the mouse
+redshift & # filter blue light
+dunst & # notification daemon
unclutter --timeout 10 --fork # hide mouse after 2s
+clout push-watch & # could with rsync
case "$(cat /etc/hostname)" in
cacharle-main)
diff --git a/local/bin/clout b/local/bin/clout
index 80f19bb..76320da 100755
--- a/local/bin/clout
+++ b/local/bin/clout
@@ -1,28 +1,64 @@
#!/bin/sh
-usage() {
- echo "Usage: $0 push/pull [rsync args...]"
+assert_command_exists() {
+ command -v "$1" > /dev/null && return
+ echo "Error: command not found: '$1'"
+ [ -n "$2" ] && echo "$2"
+ exit 1
}
-[ -z "$1" ] && usage && exit 1
+assert_command_exists rsync
-RSYNC_ARGS="$(echo "$*" | cut -d ' ' -f 2-)"
-RSYNC_CMD="rsync -avh --progress --compress $RSYNC_ARGS"
+usage_exit() {
+ echo "Usage: $(basename "$0") push/pull/push-watch/pull-watch [rsync args...]"
+ exit 2
+}
+
+[ -z "$1" ] && usage_exit
-REMOTE_USER=charles
-REMOTE_HOST=cacharle.xyz
+# Parameter expansion is undifined with $* and $@
+rsync_args=$([ -z "$2" ] || echo "$*")
+rsync_cmd="rsync -avh --progress --compress ${rsync_args#* }"
-SYNC_DIR="cacharle-sync/"
-SYNC_PATH="$HOME/$SYNC_DIR"
+remote_user=charles
+remote_host=cacharle.xyz
+remote="$remote_user@$remote_host"
+
+# '/' suffix is significant for rsync to know if it needs to copy in the directory or the directory itself
+sync_dir="clout-sync/"
+sync_path="${XDG_DATA_HOME:-$HOME/.sync}/$sync_dir"
+
+create_sync_dirs() {
+ # --mkpath only available in latest version of rsync (not in debian repositories)
+ [ ! -d "$sync_path" ] && mkdir -p "$sync_path"
+ # shellcheck disable=SC2029
+ ssh "$remote" "[ ! -d \"\$HOME/$sync_dir\" ] && mkdir -pv \"\$HOME/$sync_dir\""
+}
case "$1" in
push)
- $RSYNC_CMD "$SYNC_PATH" "$REMOTE_USER@$REMOTE_HOST:$SYNC_DIR"
+ create_sync_dirs
+ $rsync_cmd "$sync_path" "$remote:$sync_dir"
;;
pull)
- $RSYNC_CMD "$REMOTE_USER@$REMOTE_HOST:$SYNC_DIR" "$SYNC_PATH"
+ create_sync_dirs
+ $rsync_cmd "$remote:$sync_dir" "$sync_path"
+ ;;
+ push-watch)
+ assert_command_exists inotifywait "Install inotify-tools package on ArchLinux"
+ while true
+ do
+ echo 'Waiting for syncable content'
+ inotifywait -q -r -e modify -e create "$sync_path"
+ clout push
+ done
+ ;;
+ dump-config)
+ echo "rsync command: $rsync_cmd"
+ echo "remote: $remote"
+ echo "sync path: $sync_path"
;;
*)
- usage && exit 1
+ usage_exit
;;
esac