diff --git a/.dotter/global.toml b/.dotter/global.toml index 06895f8..9efd8c6 100644 --- a/.dotter/global.toml +++ b/.dotter/global.toml @@ -38,8 +38,6 @@ ssh = "~" "terminal/.config/vifm/vifmrc" = { target = "~/.config/vifm/vifmrc", type = "symbolic" } terminal = "~" -# LINUX: A linux machine, with systemd enabled, auto-mounting set up and a nice productivity suite. - [linux] depends = ["base", "disks", "pass", "office", "services", "social", "writing"] @@ -66,8 +64,6 @@ office = "~" "services/README.md" = { target = "~/NOWHERE", type = "symbolic", if = "false" } "services/usv.sh" = { target = "~/.config/sh/alias.d/usv.sh", type = "symbolic" } "services/sv" = { target = "~/.config/service", type = "symbolic"} -# FIXME: Disabling existing systemd services for the moment -"services/systemd" = { target = "~/NOWHERE", type = "symbolic", if = "false" } services = "~" [social.files] diff --git a/office/.config/goimapnotify/goimapnotify.yaml b/office/.config/goimapnotify/goimapnotify.yaml new file mode 100644 index 0000000..c014443 --- /dev/null +++ b/office/.config/goimapnotify/goimapnotify.yaml @@ -0,0 +1,10 @@ +configurations: + - host: imap.example.com + port: 993 + tls: true + tlsOptions: + starttls: false + boxes: + - mailbox: INBOX + onNewMail: neomutt-syncmail purelymail-inbox + onNewMailPost: 'notify-send "Incoming mail"' diff --git a/office/.local/bin/neomutt-syncmail b/office/.local/bin/neomutt-syncmail index d52ce92..5303a60 100755 --- a/office/.local/bin/neomutt-syncmail +++ b/office/.local/bin/neomutt-syncmail @@ -39,26 +39,35 @@ # MBSYNC_PASSWORD_FILE="/path/to/gpg/file.gpg" # What to run before and after decrypting the password file. -PASSWORD_CMD="pass open -t 1min" +if pass coffin -v 1>/dev/null 2>&1; then + PASSWORD_CMD="pass open -t 1min" +fi + # POST_PASSWORD_CMD="" +PING_TARGET="9.9.9.9" + prehook() { - if [ -n "$MBSYNC_PRE" ]; then + if [ "$MBSYNC_PRE" != "" ]; then eval "$MBSYNC_PRE" return 0 fi checkwarnuser - imapfilter -c "${XDG_CONFIG_HOME:-$HOME/.config}/imapfilter/config.lua" + if command -v imapfilter 1>/dev/null 2>&1; then + imapfilter -c "${XDG_CONFIG_HOME:-$HOME/.config}/imapfilter/config.lua" + fi } posthook() { - if [ -n "$MBSYNC_POST" ]; then + if [ "$MBSYNC_POST" != "" ]; then eval "$MBSYNC_POST" return 0 fi - notmuch new 2>/dev/null - countnew + if command -v notmuch 1>/dev/null 2>&1; then + notmuch new 2>/dev/null + countnew + fi } # use notmuch to index incoming mail and set the @@ -70,7 +79,7 @@ countnew() { # fail the routine and optionally send a message why fail() { - [ -n "$1" ] && echo "$1" + [ "$1" != "" ] && echo "$1" exit 1 } @@ -80,7 +89,7 @@ checkmail() { checkonline() { # Ping 1.1.1.1 to confirm that we are on the internet - ping -c 1 "1.1.1.1" >/dev/null 2>/dev/null || fail "checkmail can not access the internet." + ping -c 1 "$PING_TARGET" >/dev/null 2>/dev/null || fail "checkmail cannot access the internet." } # warn user that he has to enter his password in a moment @@ -94,15 +103,15 @@ checkwarnuser() { } enablegpgagent() { - [ -n "$agt" ] && return + [ "$agt" != "" ] && return - if [ -n "$PASSWORD_CMD" ]; then + if [ "$PASSWORD_CMD" != "" ]; then IFS=" " read -r -a PASSWORD_CMD <<<"$PASSWORD_CMD" # shellcheck disable=SC2068 - agt=$(${PASSWORD_CMD[@]}) + agt=$("${PASSWORD_CMD[@]}") fi - if [ -n "$POST_PASSWORD_CMD" ]; then + if [ "$POST_PASSWORD_CMD" != "" ]; then IFS=" " read -r -a POST_PASSWORD_CMD <<<"$POST_PASSWORD_CMD" "${POST_PASSWORD_CMD[@]}" fi @@ -138,7 +147,7 @@ if [ "$1" = "raw" ]; then checkmail exit # any other argument passed through selects mbsync targets -elif [ -n "$1" ]; then +elif [ "$1" != "" ]; then selected_mailbox="$1" fi @@ -153,7 +162,7 @@ main() { fi tries=$((tries + 1)) - if [ $tries -gt "${MBSYNC_MAX_TRIES:-3}" ]; then + if [ "$tries" -gt "${MBSYNC_MAX_TRIES:-3}" ]; then fail "maximum retries reached without success." fi done diff --git a/office/.local/bin/mail-searchcontacts b/office/.local/bin/notmuch-contacts similarity index 95% rename from office/.local/bin/mail-searchcontacts rename to office/.local/bin/notmuch-contacts index 65c1f3c..0504b37 100755 --- a/office/.local/bin/mail-searchcontacts +++ b/office/.local/bin/notmuch-contacts @@ -1,7 +1,7 @@ #!/usr/bin/env sh # gets known e-mail adresses out of the current notmuch database # -# called like `mail-searchcontacts [myadress]` +# called like `notmuch-contacts [myadress]` # # where myaddress can be anything that connects mails to their adresses: # if directly found in the 'from': field, it will return those adresses diff --git a/services/systemd/.config/systemd/user/dirmngr.service b/services/systemd/.config/systemd/user/dirmngr.service deleted file mode 100644 index 3c060cd..0000000 --- a/services/systemd/.config/systemd/user/dirmngr.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=GnuPG network certificate management daemon -Documentation=man:dirmngr(8) -Requires=dirmngr.socket - -[Service] -ExecStart=/usr/bin/dirmngr --supervised -ExecReload=/usr/bin/gpgconf --reload dirmngr diff --git a/services/systemd/.config/systemd/user/dirmngr.socket b/services/systemd/.config/systemd/user/dirmngr.socket deleted file mode 100644 index ebabf89..0000000 --- a/services/systemd/.config/systemd/user/dirmngr.socket +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=GnuPG network certificate management daemon -Documentation=man:dirmngr(8) - -[Socket] -ListenStream=%t/gnupg/S.dirmngr -SocketMode=0600 -DirectoryMode=0700 - -[Install] -WantedBy=sockets.target diff --git a/services/systemd/.config/systemd/user/gpg-agent-browser.socket b/services/systemd/.config/systemd/user/gpg-agent-browser.socket deleted file mode 100644 index bc8d344..0000000 --- a/services/systemd/.config/systemd/user/gpg-agent-browser.socket +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=GnuPG cryptographic agent and passphrase cache (access for web browsers) -Documentation=man:gpg-agent(1) - -[Socket] -ListenStream=%t/gnupg/S.gpg-agent.browser -FileDescriptorName=browser -Service=gpg-agent.service -SocketMode=0600 -DirectoryMode=0700 - -[Install] -WantedBy=sockets.target diff --git a/services/systemd/.config/systemd/user/gpg-agent-extra.socket b/services/systemd/.config/systemd/user/gpg-agent-extra.socket deleted file mode 100644 index 5b87d09..0000000 --- a/services/systemd/.config/systemd/user/gpg-agent-extra.socket +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=GnuPG cryptographic agent and passphrase cache (restricted) -Documentation=man:gpg-agent(1) - -[Socket] -ListenStream=%t/gnupg/S.gpg-agent.extra -FileDescriptorName=extra -Service=gpg-agent.service -SocketMode=0600 -DirectoryMode=0700 - -[Install] -WantedBy=sockets.target diff --git a/services/systemd/.config/systemd/user/gpg-agent-ssh.socket b/services/systemd/.config/systemd/user/gpg-agent-ssh.socket deleted file mode 100644 index 798c1d9..0000000 --- a/services/systemd/.config/systemd/user/gpg-agent-ssh.socket +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=GnuPG cryptographic agent (ssh-agent emulation) -Documentation=man:gpg-agent(1) man:ssh-add(1) man:ssh-agent(1) man:ssh(1) - -[Socket] -ListenStream=%t/gnupg/S.gpg-agent.ssh -FileDescriptorName=ssh -Service=gpg-agent.service -SocketMode=0600 -DirectoryMode=0700 - -[Install] -WantedBy=sockets.target diff --git a/services/systemd/.config/systemd/user/gpg-agent.service b/services/systemd/.config/systemd/user/gpg-agent.service deleted file mode 100644 index a050fcc..0000000 --- a/services/systemd/.config/systemd/user/gpg-agent.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=GnuPG cryptographic agent and passphrase cache -Documentation=man:gpg-agent(1) -Requires=gpg-agent.socket - -[Service] -ExecStart=/usr/bin/gpg-agent --supervised -ExecReload=/usr/bin/gpgconf --reload gpg-agent diff --git a/services/systemd/.config/systemd/user/gpg-agent.socket b/services/systemd/.config/systemd/user/gpg-agent.socket deleted file mode 100644 index 4257c2c..0000000 --- a/services/systemd/.config/systemd/user/gpg-agent.socket +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=GnuPG cryptographic agent and passphrase cache -Documentation=man:gpg-agent(1) - -[Socket] -ListenStream=%t/gnupg/S.gpg-agent -FileDescriptorName=std -SocketMode=0600 -DirectoryMode=0700 - -[Install] -WantedBy=sockets.target diff --git a/services/systemd/.config/systemd/user/mbsync.service b/services/systemd/.config/systemd/user/mbsync.service deleted file mode 100644 index cb86e0f..0000000 --- a/services/systemd/.config/systemd/user/mbsync.service +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Mailbox synchronization service -Wants=network-online.target gpg-agent.socket -After=network.target network-online.target dbus.socket gpg-agent.socket - -[Service] -Type=oneshot -# workaround to allow relative executable invocation (i.e. current users' home dir) -ExecStart=/bin/bash -c '%h/.local/bin/neomutt-syncmail' diff --git a/services/systemd/.config/systemd/user/mbsync.timer b/services/systemd/.config/systemd/user/mbsync.timer deleted file mode 100644 index e15db08..0000000 --- a/services/systemd/.config/systemd/user/mbsync.timer +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Mailbox synchronization timer - -[Timer] -OnBootSec=1m -OnUnitActiveSec=1h -Unit=mbsync.service - -[Install] -WantedBy=timers.target diff --git a/services/systemd/.config/systemd/user/sockets.target.wants/dirmngr.socket b/services/systemd/.config/systemd/user/sockets.target.wants/dirmngr.socket deleted file mode 120000 index ce41479..0000000 --- a/services/systemd/.config/systemd/user/sockets.target.wants/dirmngr.socket +++ /dev/null @@ -1 +0,0 @@ -../dirmngr.socket \ No newline at end of file diff --git a/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent-browser.socket b/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent-browser.socket deleted file mode 120000 index 7f3e9b7..0000000 --- a/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent-browser.socket +++ /dev/null @@ -1 +0,0 @@ -../gpg-agent-browser.socket \ No newline at end of file diff --git a/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent-extra.socket b/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent-extra.socket deleted file mode 120000 index 5a1bed5..0000000 --- a/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent-extra.socket +++ /dev/null @@ -1 +0,0 @@ -../gpg-agent-extra.socket \ No newline at end of file diff --git a/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent-ssh.socket b/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent-ssh.socket deleted file mode 120000 index 3b40290..0000000 --- a/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent-ssh.socket +++ /dev/null @@ -1 +0,0 @@ -../gpg-agent-ssh.socket \ No newline at end of file diff --git a/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent.socket b/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent.socket deleted file mode 120000 index 8b9f67c..0000000 --- a/services/systemd/.config/systemd/user/sockets.target.wants/gpg-agent.socket +++ /dev/null @@ -1 +0,0 @@ -../gpg-agent.socket \ No newline at end of file diff --git a/services/systemd/.config/systemd/user/timers.target.wants/mbsync.timer b/services/systemd/.config/systemd/user/timers.target.wants/mbsync.timer deleted file mode 120000 index fa56ef4..0000000 --- a/services/systemd/.config/systemd/user/timers.target.wants/mbsync.timer +++ /dev/null @@ -1 +0,0 @@ -../mbsync.timer \ No newline at end of file diff --git a/services/systemd/.local/share/services/git-sync b/services/systemd/.local/share/services/git-sync deleted file mode 100755 index 27f9bf4..0000000 --- a/services/systemd/.local/share/services/git-sync +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env sh -# -# Keeps a git directory synced by automatically committing every x seconds. -# After y number of runs without changes automatically pushes the directory to a remote. - -# time in seconds to check for changes to commit -TIME_TO_COMMIT=${GS_TIME_TO_COMMIT:-120} -# amount of times to check for changes *without changes occurring* to push to origin -UNCHANGED_RUNS_TO_PUSH=${GS_UNCHANGED_RUNS_TO_PUSH:-30} - -# logging verbosity level -- 0=error, 1=info, 2=debug -VERBOSITY=${GS_LOG_VERBOSITY:-1} - -set_target() { - [ -z "$GS_TARGETDIR" ] && [ -z "$1" ] && { - msg "ERROR: git-sync requires a target directory to keep in sync to be passed in." 0 - exit 1 - } - DIR="${GS_TARGETDIR:-$1}" -} - -pull() { - msg "Pulling upstream changes into $DIR" - run_git pull --ff-only --ff -} - -commit() { - msg "Committing changes to $DIR" - run_git add . - # shellcheck disable=2039 - run_git commit --no-gpg-sign -m "Git sync: $(date +%F_%R) from ${HOSTNAME:-"${HOST:-undefined}"}" -} - -push() { - msg "No changes for $((UNCHANGED_RUNS_TO_PUSH * TIME_TO_COMMIT)) seconds, pushing to origin" - run_git push -} - -should_commit() { - if [ "$(run_git diff-files --name-only | wc -l)" -eq 0 ]; then - msg "No changes to commit in $DIR" 2 - false - else - msg "Found changes to commit in $DIR" 2 - true - fi -} - -should_push() { - if [ "$no_change_cycle" -ge "$UNCHANGED_RUNS_TO_PUSH" ]; then - true - else - false - fi -} - -should_pull() { - run_git fetch - # shellcheck disable=1083 - if [ "$(run_git rev-parse HEAD)" = "$(run_git rev-parse @{u})" ]; then - false - else - true - fi -} - -run_git() { - git -C "$DIR" "$@" -} - -# echos its first argument -# verbosity level optionally set through second argument -# default verbosity 1 (info), can be set to 2 (debug), or 0 (error) -msg() { - lvl=${2:-1} - [ "$lvl" -gt "$VERBOSITY" ] && return 0 - - echo "$1" -} - -watch_changes() { - no_change_cycle=0 - while true; do - if should_pull; then - pull - fi - - if should_commit; then - commit - no_change_cycle=0 - fi - - if should_push; then - push - no_change_cycle=-9999 - fi - - msg "No changes for $((no_change_cycle * TIME_TO_COMMIT)) of $((UNCHANGED_RUNS_TO_PUSH * TIME_TO_COMMIT)) seconds, going back to sleep for $((TIME_TO_COMMIT)) seconds." 2 - - no_change_cycle=$((no_change_cycle + 1)) - sleep "$TIME_TO_COMMIT" - done -} - -main() { - set_target "$1" - - watch_changes -} - -main "$1" diff --git a/services/systemd/.local/share/services/x-started-confirm.sh b/services/systemd/.local/share/services/x-started-confirm.sh deleted file mode 100755 index 3dc9489..0000000 --- a/services/systemd/.local/share/services/x-started-confirm.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -# from: https://superuser.com/questions/759759/writing-a-service-that-depends-on-xorg/1351489#1351489 - -COUNTER=0 - -while true; do - # Check whether or not socket exists - if [ -S /tmp/.X11-unix/X0 ]; then - exit 0 - fi - - ((++COUNTER)) - - if [ "$COUNTER" -gt 20 ]; then - printf "X did not start in time\n" - exit 1 - fi - printf "X not yet started, counter at %s\n" "$COUNTER" - sleep 1 -done