Compare commits

...

9 Commits

Author SHA1 Message Date
Emre AKYÜZ
87c4c176da
Merge b157d54410b152095f6475e8df3fcdb16207aad8 into 0cc589bcadf5a8ce6aee2706e749fee878ccca75 2023-10-29 02:18:15 -05:00
Luke Smith
0cc589bcad
Merge branch 'master' of github.com:LukeSmithxyz/voidrice 2023-10-28 08:41:43 -04:00
Luke Smith
6ba48b2733
fix #1366 2023-10-28 08:41:26 -04:00
Lalle
1e3adf9c03
Launch dwm in a dbus session (#1340)
* Launch dwm in a dbus session

* Add ssh-agent

* Update dbus env

* Update xprofile
2023-10-27 19:42:32 +00:00
appeasementPolitik
ca8cb1f6a7
Update sb-mailbox in statusbar on closing neomutt (#1329) 2023-10-27 18:58:40 +00:00
poeplva
54c0aa2af8
none of the encrypted devices are listed if no drives are decrypted already (#1338)
The part
```
for open in $decrypted; do
		[ "$uuid" = "$open" ] && break 1
done
```
exits with `0` if the variable `$decrypted` is empty, causing none of the encrypted devices to be put into the `$unopenedluks` variable. This commit fixes this problem.
2023-10-27 18:58:05 +00:00
Emre AKYÜZ
bca6b403eb
Unpack Function for LF Without Aunpack (#1334)
We can simply eliminate the usage of an external tool by adding a simple case statement to handle different types of compressed files.
2023-10-27 18:54:15 +00:00
Dawid Potocki
42f3efb4b0
Add xdg-terminal-exec script to launch "$TERMINAL" for .desktop files (#1302) 2023-10-27 18:52:44 +00:00
Emre AKYÜZ
b157d54410
improve bulkrename in lf
You can see the example video below (15 seconds).

## Improvements
- Directories are excluded. You can't mistakenly rename directories now or you don't have to exclude them manually.

- The extensions are excluded. Therefore, creating macros or editing in general is easier in the editor and there is no chance of messing up extensions. The extensions will be there as they are after editing.

## Justifications
- The original code fetched filenames without any specific order. In the new version, filenames are fetched in version sort order (sort -fV) to ensure a natural order, making it more intuitive for users. This is particularly useful when dealing with sequences of files (like episodes of a TV show or a series of images).

- Previously, the code used ls to get the file names. This approach can be problematic. The updated version uses find, a more robust and dependable method to retrieve files, and cut to trim the unnecessary ./ from the beginning. This change also helps us exclude directories from the list.

- It now separately stores the base filenames and their extensions. This prevents accidental renaming of file extensions, ensuring that only the desired part of the filename is modified. It adds an extra layer of precision, ensuring that a user doesn't mistakenly rename a file extension.

- It utilizes multiple file descriptors (3, 4, and 5) to read from the temporary files concurrently. This allows for a more structured loop when renaming files, making the code clearer and more maintainable. This removes the need for line by line operations and makes the process much more minimal and faster.

- The script can still work with Dash as a /bin/sh link.

## Performance Optimizations:
- The script still has minimal dependencies.

- Instead of reading and writing the entire content of files multiple times, the script uses the mktemp command to create temporary files and then employs file descriptors to read them concurrently. This minimizes file IO operations that can be a significant bottleneck.

- The script processes most data in-memory. Reading from and writing to memory is much faster than disk operations as you already know.

- The while loop uses file descriptors to read three files concurrently. This parallelization minimizes the number of loop iterations, making the loop more efficient than sequential alternatives.
2023-09-12 15:08:21 +03:00
7 changed files with 45 additions and 17 deletions

View File

@ -58,7 +58,22 @@ cmd extract ${{
printf "%s\n\t" "$fx"
printf "extract?[y/N]"
read ans
[ $ans = "y" ] && aunpack $fx
[ $ans = "y" ] && {
case $fx in
*.tar.bz2) tar xjf $fx ;;
*.tar.gz) tar xzf $fx ;;
*.bz2) bunzip2 $fx ;;
*.rar) unrar e $fx ;;
*.gz) gunzip $fx ;;
*.tar) tar xf $fx ;;
*.tbz2) tar xjf $fx ;;
*.tgz) tar xzf $fx ;;
*.zip) unzip $fx ;;
*.Z) uncompress $fx ;;
*.7z) 7z x $fx ;;
*.tar.xz) tar xf $fx ;;
esac
}
}}
cmd delete ${{
@ -95,24 +110,32 @@ cmd copyto ${{
cmd setbg "$1"
cmd bulkrename ${{
tmpfile_old="$(mktemp)"
tmpfile_new="$(mktemp)"
tmpfile_old="$(mktemp)"
tmpfile_new="$(mktemp)"
tmpfile_ext="$(mktemp)"
[ -n "$fs" ] && fs=$(basename -a $fs) || fs=$(ls)
[ -n "$fs" ] && fs=$(basename -a $fs | sort -fV) || fs=$(find . -maxdepth 1 -type f | cut -c 3- | sort -fV)
echo "$fs" > "$tmpfile_old"
echo "$fs" > "$tmpfile_new"
$EDITOR "$tmpfile_new"
for f in $fs; do
echo "${f%.*}" >> "$tmpfile_old"
echo "${f##*.}" >> "$tmpfile_ext"
done
[ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new"; exit 1; }
cp "$tmpfile_old" "$tmpfile_new"
$EDITOR "$tmpfile_new"
paste "$tmpfile_old" "$tmpfile_new" | while IFS="$(printf '\t')" read -r src dst
do
[ "$src" = "$dst" ] || [ -e "$dst" ] || mv -- "$src" "$dst"
done
[ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new" "$tmpfile_ext"; exit 1; }
rm -f "$tmpfile_old" "$tmpfile_new"
lf -remote "send $id unselect"
exec 3<"$tmpfile_old"
exec 4<"$tmpfile_ext"
exec 5<"$tmpfile_new"
while IFS= read -r old_name <&3 && IFS= read -r ext <&4 && IFS= read -r new_name <&5; do
[ "$old_name" = "$new_name" ] || [ -e "$new_name.$ext" ] || mv -- "$old_name.$ext" "$new_name.$ext"
done
rm -f "$tmpfile_old" "$tmpfile_new" "$tmpfile_ext"
lf -remote "send $id unselect"
}}
# Bindings

1
.config/sxiv Symbolic link
View File

@ -0,0 +1 @@
nsxiv

View File

@ -13,5 +13,6 @@ if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile" ]; then
else
. "$HOME/.xprofile"
fi
# Activate dbus variables
dbus-update-activation-environment --all
ssh-agent dwm

View File

@ -36,7 +36,7 @@ filter() { sed "s/ /:/g" | awk -F':' '$7==""{printf "%s%s (%s) %s\n",$1,$3,$5,$6
unopenedluks="$(for drive in $allluks; do
uuid="${drive%% *}"
uuid="${uuid//-}" # This is a bashism.
for open in $decrypted; do
[ -n "$decrypted" ] && for open in $decrypted; do
[ "$uuid" = "$open" ] && break 1
done && continue 1
echo "🔒 $drive"

View File

@ -4,7 +4,7 @@
# When clicked, brings up `neomutt`.
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e neomutt ;;
1) setsid -w -f "$TERMINAL" -e neomutt; pkill -RTMIN+12 "${STATUSBAR:-dwmblocks}" ;;
2) setsid -f mw -Y >/dev/null ;;
3) notify-send "📬 Mail module" "\- Shows unread mail
- Shows 🔃 if syncing mail

3
.local/bin/xdg-terminal-exec Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
"$TERMINAL" -e "$@"