1
0
Fork 0

add trash-prune, fix trash-restore,write dbus addy

Updates submodules, minor aesthetic changes
This commit is contained in:
Luca Bilke 2023-11-24 15:46:14 +01:00
parent 73eb7bf6c9
commit 72882600c5
13 changed files with 71 additions and 67 deletions

View File

@ -14,4 +14,6 @@ fi
. "$X11_CONFIG/xprofile"
exec dwm
echo $DBUS_SESSION_BUS_ADDRESS > $XDG_STATE_HOME/dbus_session_address
dwm

View File

@ -36,7 +36,7 @@ cmd lazygit ${{
clear
if [ ! -e "$PWD/.git" ]; then
echo "Not in a git repository. Create a new git repository? (y/n): "
[ $(echo "y\nn" | fzf) = "y" ] && git init && lazygit -p $PWD
[ $(echo "Yes\nNo" | fzf) = "Yes" ] && git init && lazygit -p $PWD
else
lazygit -p $PWD
fi
@ -147,12 +147,17 @@ cmd fzfgrep ${{
[ -n "$res" ] && lf -remote "send $id select \"$res\""
}}
# cmd fzfworkon ${{
# workon -n $(workon | fzf)
# }}
# Bindings
map <c-c>a fzfsearch
map <c-c>t fzftags
map <c-c>m fzfmarks
map <c-c>f fzfshortcut
map <c-c>g fzfgrep
# map w fzfworkon
map D trash
map <c-d> $trash-restore $PWD
map T delete

View File

@ -1,14 +0,0 @@
# Important Note
These cronjobs have components that require information about your current display to display notifications correctly.
When you add them as cronjobs, I recommend you precede the command with commands as those below:
$()$(
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus
export DISPLAY=:0
. $HOME/.zprofile
then_command_goes_here
)$()
This ensures that notifications will display, xdotool commands will function and environmental variables will work as well.

View File

@ -1,24 +1,14 @@
#!/bin/sh
# Syncs repositories and downloads updates, meant to be run as a cronjob.
notify-send " Repository Sync" "Checking for package updates..."
askupgrade() {
[ "$(notify-send -c updates --action=Yes=Yes --action=No=No " Repository Sync" "Updates available. Update now?")" = 'Yes' ] && $TERMINAL -e upgrades
}
confirmcheck() {
notify-send " Repository Sync" "Sync complete. No new packages for update."
}
if command -v apt 1>/dev/null 2>&1; then
n=$(sudo apt upgrade -dy 2>/dev/null | grep -m1 '^[0-9]\+ upgraded,' | tr -cd '0-9' | cut -c1-2)
if [ "$n" = '' ]; then
notify-send "Error downloading updates." "Check your internet connection, if apt is already running, or run update manually to see errors."
elif [ "$n" = 00 ]; then
confirmcheck
else
notify-send -u critical "Error downloading updates." "Check your internet connection, if apt is already running, or run update manually to see errors."
elif [ "$n" != 00 ]; then
askupgrade
fi
elif command -v xbps-install 1>/dev/null 2>&1; then
@ -26,11 +16,9 @@ elif command -v xbps-install 1>/dev/null 2>&1; then
n="$(wc -l < /tmp/xbps_updates)"
ne="$(grep broken /tmp/xbps_errors | wc -l)"
n="$(xbps-install -M -n -u | grep -Fe update -e install | wc -l)"
if [ "$n" = "0" ] && [ "$ne" = "0" ]; then
confirmcheck
if [ "$n" != "0" ] && [ "$ne" != "0" ]; then
notify-send -u critical "Error downloading updates." "$(cut -d " " -f 1,5 /tmp/xbps_errors)"
elif [ "$n" -gt 1 ] && [ "$ne" = "0" ]; then
askupgrade
else
notify-send "Error downloading updates." "$(cut -d " " -f 1,5 /tmp/xbps_errors)"
fi
fi

View File

@ -1,15 +0,0 @@
#!/bin/sh
# Set as a cron job to check for new RSS entries for newsboat.
# If newsboat is open, sends it an "R" key to refresh.
/usr/bin/notify-send " Updating RSS feeds..."
pgrep -f newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name "^newsboat$")" R && exit
echo " 痢" >/tmp/newsupdate
pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"
/usr/bin/newsboat -x reload
rm -f /tmp/newsupdate
pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"
/usr/bin/notify-send " RSS feed update complete."

41
.local/bin/cron/trash-prune Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh
IFS='
'
days=${1:-7}
types=${2:-ext2,ext3,ext4,xfs,btrfs,vfat,nfs}
getfsroot() {
printf "%s" "$(df "$1" --output=target | tail -1)"
}
list_trash_dirs() {
for mnt in $(findmnt -Py -t "$types"); do
eval $mnt
if [ "$TARGET" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ]; then
echo "${XDG_DATA_HOME:-$HOME/.local/share}/Trash"
elif [ "$TARGET" = "/" ]; then
echo "/.Trash"
else
echo "${TARGET}/.Trash"
fi
done
}
prune_dir() {
[ -w "$1" ] || return 1
for file in "$1"/info/*; do
[ "$(head -1 "$file")" = "[Trash Info]" ] || continue
if [ "$(date -ud "$days days ago" +%s)" -gt "$(date -ud "$(grep DeletionDate "$file" | cut -d '=' -f2)" +%s)" ]; then
file=$(basename "$file")
echo "$file too old!"
rm "$1/info/$file"
rm "$1/files/$file"
fi
done
}
for dir in $(list_trash_dirs); do
prune_dir $dir || echo "Not pruning $dir" >&2
done

View File

@ -1,13 +1,13 @@
#!/bin/sh
reset="\033[0m"
big="\033[12m"
# reset="\033[0m"
# big="\033[12m"
IFS='
'
types=${1:-ext2,ext3,ext4,xfs,btrfs,vfat}
first=true
for mnt in $(findmnt -Py -t $types); do
for mnt in $(findmnt -Py -t "$types"); do
[ "$first" = "false" ] && printf " | "
eval $mnt
[ -d "$TARGET" ] || break

View File

@ -8,18 +8,15 @@ list() {
# 1st arg is trash files directory
# 2nd arg is directory to match trash files for
[ ! "$(command ls -A "$1")" ] && exit 1
for file in "$1"/*; do
[ "$(head -1 "$file")" = "[Trash Info]" ] &&
filepath=$(grep Path "$file" | cut -d '=' -f2) &&
echo "$filepath" | grep -qP "^$2/[^/]+$" &&
printf "%s %s %s\n" \
"$(basename "$file")" \
"$filepath" \
"$(date -d "$(grep Date "$file" | cut -d '=' -f2)" +'%x %X')"
done
while read -r file; do
filepath=$(grep Path "$file" | cut -d '=' -f2) || continue
echo "$filepath" | grep -qP "^$2/[^/]+$" || continue
printf "%s %s %s\n" "$(basename "$file")" "$filepath" "$(date -d "$(grep DeletionDate "$file" | cut -d '=' -f2)" +'%x %X')"
done <<EOF
$(grep -l '[Trash Info]' "$1"/* "$1"/.* 2>/dev/null)
EOF
}
fsroot="$(getfsroot "$PWD")"
if [ "$fsroot" = "$(getfsroot "${XDG_DATA_HOME:-$HOME/.local/share}")" ]; then
@ -31,5 +28,5 @@ fi
sel="$(list "$basedir/info" "$PWD" | fzf)"
file="$basedir/files/$(echo "$sel" | cut -d '' -f1)"
dest="$(echo "$sel" | cut -d '' -f3)"
command mv -ib "$file" "$dest"
command rm "$basedir/info/$(echo "$sel" | cut -d '' -f1)"
mv -ib "$file" "$dest"
rm "$basedir/info/$(echo "$sel" | cut -d '' -f1)"

@ -1 +1 @@
Subproject commit 158ee8a8ec25314523d8c5d819a84358af9bf69a
Subproject commit 8537c3d39c01c84c854781af01e050677ec62e01

@ -1 +1 @@
Subproject commit 17b6f68ab4a701ee4a8b01596fd4e810ceea2e61
Subproject commit 38ddeff2c430311867f11aabdace36cbf683012e

@ -1 +1 @@
Subproject commit f8c27ebf0e59cdf2536f5ba8b0019eded565a445
Subproject commit 606d9be33728041cbf740d1b2c2b134576441e50

@ -1 +1 @@
Subproject commit c844a7936a592aad3693c09e65a4563d2ceba9f1
Subproject commit fcb3ded4546c3ae24f1a38473976cd5a3651691a

@ -1 +1 @@
Subproject commit c1c84d6fa5479b82266f2f6a140e61991e509b60
Subproject commit 3fa572fee205c8ae85a74e4e350df2daf3c6ed9d