summaryrefslogtreecommitdiffstats
path: root/.local
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2023-01-31 21:13:10 +0100
committerJoe <bousset.rudy@gmail.com>2023-01-31 21:13:10 +0100
commitae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f (patch)
tree7341031ed0f84167350e95f48397761ef6544ad9 /.local
parentfbsd merge (diff)
parentup (diff)
downloaddotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.tar.gz
dotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.tar.bz2
dotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.tar.xz
dotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.tar.zst
dotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.zip
Merge branch 'master' of gitjoe.xyz:dotfiles-bsd
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/conky_cover.sh67
-rwxr-xr-x.local/bin/dmlog17
-rwxr-xr-x.local/bin/dmpass6
-rwxr-xr-x.local/bin/fetch_mail.sh43
-rwxr-xr-x.local/bin/powercmd63
-rwxr-xr-x.local/bin/status/sb-mailbox25
-rwxr-xr-x.local/bin/status/sb-tools3
7 files changed, 178 insertions, 46 deletions
diff --git a/.local/bin/conky_cover.sh b/.local/bin/conky_cover.sh
new file mode 100755
index 0000000..ffdd403
--- /dev/null
+++ b/.local/bin/conky_cover.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# cover.sh - Download cover from Last.fm and overlay with image
+#
+# Florian <floriandejonckheere.be>
+#
+# bug: it detects the artist change twice
+
+## CONFIGURATION ##
+# Folder for cached album art
+# Don't use ~, as conky will treat it as a regular directory name
+# CACHE="$HOME/.cache/covers"
+# API Key for Last.fm
+# APIKEY="b25b959554ed76058ac220b7b2e0a026"
+# Log file, only for debugging purposes
+LOG=/tmp/conky-mpd.log
+TMP=/tmp/conkympd.tmp
+
+# Check for vital commands
+# CMD="mpc curl convert"
+# for CHECK in $CMD; do
+# [ ! "$CHECK" ] && echo "Command $CHECK not found. Exiting." && exit 1
+# done
+# [ ! -d "$CACHE" ] && mkdir -p "$CACHE"
+
+playing="$(mpc --format '%artist% - %album%' | head -1)"
+filedir="$(dirname "$XDG_MUSIC_DIR/$(mpc --format %file% | head -n1)")"
+
+[ ! -f $TMP ] && touch $TMP
+[ "$(cat $TMP)" == "$playing" ] && exit 0
+# [ "$(cat $TMP)" == "$playing" ] && echo "Same artist/album" >> $LOG && exit 0
+# echo "Artist/album changed: $playing" >> $LOG
+
+#[ -f "/tmp/conkyCover.png" ] && rm "/tmp/conkyCover.png"
+cp $HOME/.config/conky-mpd/nocover.png /tmp/conkyCover.png
+# echo "NoCover" >> $LOG
+
+coverfile="$(find "$filedir" -maxdepth 1 -type f \( -iname 'cover.jpg' -o -iname 'cover.png' -o -iname 'folder.jpg' -o -iname 'folder.png' -o -iname '*.jpg' -o -iname '*.png' \) -print -quit)"
+#COVER="$CACHE/$ARTIST - $ALBUM.jpg"
+## Is cover cached?
+#if [ ! -f "$COVER" ]; then
+## Nope. Download.
+# echo "Downloading cover for $ARTIST - $ALBUM" >> $LOG
+# # Download XML info
+# curl --data-urlencode artist="$ARTIST" --data-urlencode album="$ALBUM" "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=$APIKEY" -o /tmp/lastfm.xml &> /dev/null
+# echo "Exit: $?. Downloaded $(wc -l /tmp/lastfm.xml | cut -d' ' -f1) bytes." >> $LOG
+# # Strip XML and download mega large cover to cache
+# curl $(sed -n 's|<image size="mega">\(.*\)<\/image>|\1|p' /tmp/lastfm.xml) -o "$COVER" &> /dev/null
+# echo "Exit: $?" >> $LOG
+# echo "Downloaded to $COVER." >> $LOG
+#fi
+# Copy cache for processing
+# echo "Copying $coverfile." >> $LOG
+# cp "$COVER" /tmp/cover.jpg
+# Downscale to fit overlay
+# convert /tmp/cover.jpg -resize 366 /tmp/cover.png >> $LOG
+## Enlarge canvas to fit overlay
+#convert /tmp/cover.png -background none -extent 500x455-84-44 /tmp/cover.png >> $LOG
+## Overlay overlay over cover
+#convert /tmp/cover.png $HOME/.config/conky-mpd/case.png -composite /tmp/cover.png >> $LOG
+## Resize for immediate use
+# convert /tmp/cover.png -resize 120 /tmp/conkyCover.png >> $LOG
+convert "$coverfile" -resize 100 /tmp/conkyCover.png # >> $LOG
+## Set current artist
+echo "$playing" > $TMP
+#rm /tmp/cover.jpg /tmp/cover.png
+
diff --git a/.local/bin/dmlog b/.local/bin/dmlog
index 3d6ccc1..a4c0182 100755
--- a/.local/bin/dmlog
+++ b/.local/bin/dmlog
@@ -62,11 +62,11 @@ sub action
'-u',
'normal',
'shutdown',
- ' G\'night, partner!'
+ ' G\'night, partner!'
);
sleep 2;
if (OS eq 'Linux') {
- exec(LOGINCTL_PATH, 'suspend');
+ exec('systemctl', 'suspend');
}
exec(ACPI_PATH, '-s', '3');
}
@@ -84,8 +84,15 @@ sub action
if (confirm($var) == 1) {
system(EMACS_PATH, '-e', '"(save-buffers-kill-terminal)"');
if (OS eq 'Linux') {
- exec(LOGINCTL_PATH, 'reboot');
+ exec('systemctl', 'reboot');
}
+ system(
+ NOTIF_PATH,
+ '-u',
+ 'normal',
+ 'shutdown',
+ ' Rebootin\', partner!'
+ );
exec(SHUTDOWN_PATH, '-r', 'now');
}
}
@@ -97,11 +104,11 @@ sub action
'-u',
'normal',
'shutdown',
- ' Farewell, partner!'
+ ' Farewell, partner!'
);
sleep 2;
if (OS eq 'Linux') {
- exec(LOGINCTL_PATH, 'poweroff');
+ exec('systemctl', 'poweroff');
}
exec(SHUTDOWN_PATH, '-p', 'now');
}
diff --git a/.local/bin/dmpass b/.local/bin/dmpass
index 11725c7..6836d41 100755
--- a/.local/bin/dmpass
+++ b/.local/bin/dmpass
@@ -23,13 +23,15 @@ password=$(printf "%s\n" "${password_files}" | "$dmenu" -i -l 15 -m 0)
[ -n "$password" ] || exit
+p="$(pass show "$password")"
+
if [ $full -eq 1 ]; then
id=$(printf "%s" "$password" | sed 's/.*___//')
printf "%s\n" $id | { IFS= read -r pass; printf %s "$id"; } | $xdotool
xdotool key Tab
- pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
+ printf "%s\n" "$p" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
xdotool key Return
exit
fi
-pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
+printf "%s\n" "$p" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
diff --git a/.local/bin/fetch_mail.sh b/.local/bin/fetch_mail.sh
index 0375f41..c342215 100755
--- a/.local/bin/fetch_mail.sh
+++ b/.local/bin/fetch_mail.sh
@@ -11,29 +11,32 @@ mc_file="/tmp/newmailcount"
if [ -f $mc_file ]; then
pre_count=$(cat $mc_file)
else
- pre_count="$(ls "${MAIL:-/var/mail/jozan}"/main/INBOX/new | wc -l 2>/dev/null)"
- mb1="$(ls "${MAIL:-/var/mail/jozan}"/gmail_br/INBOX/new | wc -l 2>/dev/null)"
- mb2="$(ls "${MAIL:-/var/mail/jozan}"/gmail_oon/INBOX/new | wc -l 2>/dev/null)"
- mb3="$(ls "${MAIL:-/var/mail/jozan}"/gmail_tos/INBOX/new | wc -l 2>/dev/null)"
- pre_count="$((pre_count + mb1 + mb2 + mb3))"
+ pre_count="$(ls "${MAIL:-/var/mail/jozan}"/gmail_br/INBOX/new | wc -l 2>/dev/null)"
+ mb1="$(ls "${MAIL:-/var/mail/jozan}"/gmail_oon/INBOX/new | wc -l 2>/dev/null)"
+ mb2="$(ls "${MAIL:-/var/mail/jozan}"/gmail_tos/INBOX/new | wc -l 2>/dev/null)"
+ pre_count="$((pre_count + mb1 + mb2))"
+fi
+
+if ! echo test | gpg2 --sign --batch --no-tty --pinentry-mode error -o /dev/null >/dev/null 2>&1; then
+ notify-send -u low -t 6000 'mbsync' ' GPG locked'
+ exit 1
fi
killall mbsync >/dev/null 2>&1
-# notify-send -u low -t 3000 'mbsync' ' fetching mail...' >/dev/null 2>&1
-{
- mbsync -a -c /usr/home/jozan/.config/mbsync/mbsyncrc ||
- notify-send -u low -t 6000 'mbsync' ' failed to fetch mail' >/dev/null 2>&1
-}&
-gsleep 0.2
-kill -74 $(pidof dwmblocks) >/dev/null 2>&1
-fg
-post_count="$(ls "${MAIL:-/var/mail/jozan}"/main/INBOX/new | wc -l 2>/dev/null)"
-mb1="$(ls "${MAIL:-/var/mail/jozan}"/gmail_br/INBOX/new | wc -l 2>/dev/null)"
-mb2="$(ls "${MAIL:-/var/mail/jozan}"/gmail_oon/INBOX/new | wc -l 2>/dev/null)"
-mb3="$(ls "${MAIL:-/var/mail/jozan}"/gmail_tos/INBOX/new | wc -l 2>/dev/null)"
-post_count="$((post_count + mb1 + mb2 + mb3))"
+notify-send -u low -t 3000 'mbsync' ' fetching mail...' >/dev/null 2>&1
+# {
+mbsync -a -c /usr/home/jozan/.config/mbsync/mbsyncrc ||
+ notify-send -u low -t 6000 'mbsync' ' failed to fetch mail' >/dev/null 2>&1
+# }&
+# gsleep 0.2
+# kill -74 $(pidof dwmblocks) >/dev/null 2>&1
+# fg
+pre_count="$(ls "${MAIL:-/var/mail/jozan}"/gmail_br/INBOX/new | wc -l 2>/dev/null)"
+mb1="$(ls "${MAIL:-/var/mail/jozan}"/gmail_oon/INBOX/new | wc -l 2>/dev/null)"
+mb2="$(ls "${MAIL:-/var/mail/jozan}"/gmail_tos/INBOX/new | wc -l 2>/dev/null)"
+post_count="$((post_count + mb1 + mb2))"
if [ $post_count -gt $pre_count ]; then
notify-send -u normal 'NeoMutt' ' '$post_count' new mail(s)'
fi
echo $post_count >$mc_file
-sleep 1
-kill -74 $(pidof dwmblocks) >/dev/null 2>&1
+# sleep 1
+# kill -74 $(pidof dwmblocks) >/dev/null 2>&1
diff --git a/.local/bin/powercmd b/.local/bin/powercmd
new file mode 100755
index 0000000..9f85e39
--- /dev/null
+++ b/.local/bin/powercmd
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+[ -z "$1" ] && echo "no arg" && exit 1
+
+os="$(uname)"
+
+if [ "$os" = "Linux" ]; then
+ grep "Artix" /etc/issue >/dev/null 2>&1 && os=1 || os=2
+elif [ "$os" = "FreeBSD" ]; then
+ os=3
+else
+ echo "unknown OS"
+ exit 1
+fi
+
+# 1: Artix
+# 2: Pop OS
+# 3: FreeBSD
+
+case $os in
+ 1) icon=" " ;;
+ 2) icon=" " ;;
+ 3) icon=" " ;;
+esac
+
+case $1 in
+ "lock") xscreensaver-command -lock ;;
+ "sleep")
+ notify-send -u normal "sleep" "$icon G'night, partner!"
+ sleep 1
+ xscreensaver-command -lock
+ sleep 5
+ case $os in
+ 1) loginctl hibernate ;;
+ 2) systemctl suspend ;;
+ 3) acpiconf -s 3 ;;
+ esac
+ ;;
+ "reboot")
+ emacsclient -e '"(save-buffers-kill-emacs)"' >/dev/null 2>&1
+ notify-send -u normal reboot "$icon Rebootin' now!"
+ sleep 2
+ case $os in
+ 1) loginctl reboot ;;
+ 2) systemctl reboot ;;
+ 3) shutdown -r now ;;
+ esac
+ ;;
+ "poweroff")
+ emacsclient -e '"(save-buffers-kill-emacs)"' >/dev/null 2>&1
+ notify-send -u normal poweroff "$icon Farewell, partner!"
+ sleep 2
+ case $os in
+ 1) loginctl poweroff ;;
+ 2) systemctl poweroff ;;
+ 3) shutdown -p now ;;
+ esac
+ ;;
+ *)
+ echo "wrong arg"
+ exit 1
+ ;;
+esac
diff --git a/.local/bin/status/sb-mailbox b/.local/bin/status/sb-mailbox
index 0dfcbd6..f7a3786 100755
--- a/.local/bin/status/sb-mailbox
+++ b/.local/bin/status/sb-mailbox
@@ -13,10 +13,9 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-mb_a="$(ls "${MAIL:-/var/mail/jozan}"/main/INBOX/new/ | wc -l 2>/dev/null)"
-mb_b="$(ls "${MAIL:-/var/mail/jozan}"/gmail_br/INBOX/new/ | wc -l 2>/dev/null)"
-mb_c="$(ls "${MAIL:-/var/mail/jozan}"/gmail_oon/INBOX/new/ | wc -l 2>/dev/null)"
-mb_d="$(ls "${MAIL:-/var/mail/jozan}"/gmail_tos/INBOX/new/ | wc -l 2>/dev/null)"
+mb_a="$(ls "${MAIL:-/var/mail/jozan}"/gmail_br/INBOX/new/ | wc -l 2>/dev/null)"
+mb_b="$(ls "${MAIL:-/var/mail/jozan}"/gmail_oon/INBOX/new/ | wc -l 2>/dev/null)"
+mb_c="$(ls "${MAIL:-/var/mail/jozan}"/gmail_tos/INBOX/new/ | wc -l 2>/dev/null)"
sync=0
if pidof mbsync >/dev/null 2>&1; then
@@ -30,7 +29,7 @@ case "$sync" in
esac
if [ "$mb_a" -gt 0 ]; then
- echo -n "main:" $mb_a
+ echo -n "br:" $mb_a
fi
if [ "$mb_a" -gt 0 ] && [ "$mb_b" -gt 0 ]; then
@@ -38,7 +37,7 @@ if [ "$mb_a" -gt 0 ] && [ "$mb_b" -gt 0 ]; then
fi
if [ "$mb_b" -gt 0 ]; then
- echo -n "br:" $mb_b
+ echo -n "oon:" $mb_b
fi
if [ "$mb_b" -gt 0 ] && [ "$mb_c" -gt 0 ]; then
@@ -48,17 +47,5 @@ elif [ "$mb_a" -gt 0 ] && [ "$mb_c" -gt 0 ]; then
fi
if [ "$mb_c" -gt 0 ]; then
- echo -n "oon:" $mb_c
-fi
-
-if [ "$mb_c" -gt 0 ] && [ "$mb_d" -gt 0 ]; then
- echo -n " - "
-elif [ "$mb_b" -gt 0 ] && [ "$mb_d" -gt 0 ]; then
- echo -n " - "
-elif [ "$mb_a" -gt 0 ] && [ "$mb_d" -gt 0 ]; then
- echo -n " - "
-fi
-
-if [ "$mb_d" -gt 0 ]; then
- echo -n "tos:" $mb_d
+ echo -n "tos:" $mb_c
fi
diff --git a/.local/bin/status/sb-tools b/.local/bin/status/sb-tools
index 5d042a6..78508e6 100755
--- a/.local/bin/status/sb-tools
+++ b/.local/bin/status/sb-tools
@@ -1,5 +1,8 @@
#!/bin/sh
+if pidof emacs-28.2 >/dev/null 2>&1; then
+ echo -n " "
+fi
if pgrep gpg-agent >/dev/null 2>&1; then
echo -n " "
else