Created
July 19, 2022 00:10
-
-
Save mfurquimdev/9d87ccaf020e60531fb572645e107651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Modified a few lines from: | |
# https://github.com/neurosnap/lists.sh/discussions/24 | |
# | |
# Automatically scp files to https://prose.sh | |
# when $HOME/prose_sh files are changed. | |
# | |
# Setup a prose.sh account first (See https://prose.sh) | |
# | |
# Usage: | |
# | |
# * Setup a prose.sh account first (See https://prose.sh) | |
# * Update the PROSES_PATH variable if you don't want your proses to live in ~/prose_sh | |
# * Run this script | |
# | |
set -e | |
### CONFIGURATION ### | |
PROSES_PATH="$HOME/prose_sh" # Directory holding .md files | |
NOTIFY_SEND=1 # Comment out this variable if you don't want notifications | |
##################### | |
SDPATH="$HOME/.config/systemd/user" | |
mkdir "$SDPATH" "$PROSES_PATH" -p | |
cat > "$SDPATH/prose-sh.path" <<EOF | |
[Unit] | |
Description=prose.sh directory | |
[Path] | |
PathChanged=%h/prose_sh | |
Unit=prose-sh.service | |
[Install] | |
WantedBy=default.target | |
EOF | |
cat > "$SDPATH/prose-sh.service" <<EOF | |
[Unit] | |
Description=Update prose.sh | |
[Service] | |
Type=simple | |
ExecStart=%h/.config/systemd/user/prose-sh.script | |
EOF | |
cat > "$SDPATH/prose-sh.script" <<EOF | |
#!/bin/sh | |
scp ~/prose_sh/*.md prose.sh:/ | |
if [ -n "$NOTIFY_SEND" ]; then | |
notify-send "prose.sh content updated!" | |
fi | |
EOF | |
chmod +x "$SDPATH/prose-sh.script" | |
systemctl --user daemon-reload | |
systemctl --user enable prose-sh.path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment