summaryrefslogtreecommitdiff
path: root/mut
diff options
context:
space:
mode:
authorMike Vink <mike@pionative.com>2024-04-19 17:39:16 +0200
committerMike Vink <mike@pionative.com>2024-04-19 17:39:16 +0200
commite39341f567c74f88a3610adce25d42e2a3666a91 (patch)
treef12f8cf89eea186c2a005613ff07832169da22da /mut
parent985cac44e0c7b33763d0f9d26842ad5325a4a303 (diff)
update from lemptop
Diffstat (limited to 'mut')
-rwxr-xr-xmut/bin/lfub13
-rwxr-xr-xmut/bin/rotdir12
-rwxr-xr-xmut/bin/vremote50
m---------mut/dwm0
-rwxr-xr-xmut/lf/cleaner6
-rwxr-xr-xmut/lf/scope2
-rw-r--r--mut/neovim/fnl/conf/init.fnl6
-rw-r--r--mut/neovim/fnl/conf/pkgs/oil.fnl3
m---------mut/st0
9 files changed, 65 insertions, 27 deletions
diff --git a/mut/bin/lfub b/mut/bin/lfub
index 894ffde..ffcb52a 100755
--- a/mut/bin/lfub
+++ b/mut/bin/lfub
@@ -3,7 +3,6 @@
# This is a wrapper script for lb that allows it to create image previews with
# ueberzug. This works in concert with the lf configuration file and the
# lf-cleaner script.
-
set -e
cleanup() {
@@ -11,4 +10,14 @@ cleanup() {
rm "$FIFO_UEBERZUG"
}
-lf "$@"
+if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
+ lf "$@"
+else
+ [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
+ export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
+ mkfifo "$FIFO_UEBERZUG"
+ ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
+ exec 3>"$FIFO_UEBERZUG"
+ trap cleanup HUP INT QUIT TERM PWR EXIT
+ lf "$@" 3>&-
+fi
diff --git a/mut/bin/rotdir b/mut/bin/rotdir
new file mode 100755
index 0000000..d171f29
--- /dev/null
+++ b/mut/bin/rotdir
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# When I open an image from the file manager in nsxiv (the image viewer), I want
+# to be able to press the next/previous keys to key through the rest of the
+# images in the same directory. This script "rotates" the content of a
+# directory based on the first chosen file, so that if I open the 15th image,
+# if I press next, it will go to the 16th etc. Autistic, I know, but this is
+# one of the reasons that nsxiv is great for being able to read standard input.
+
+[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
+base="$(basename "$1")"
+ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }'
diff --git a/mut/bin/vremote b/mut/bin/vremote
index 75b404e..4d0d417 100755
--- a/mut/bin/vremote
+++ b/mut/bin/vremote
@@ -3,31 +3,39 @@ if [ -z "$PATH" ]; then
PATH="/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin:/usr/bin:/bin"
fi
server_pipe="$XDG_CACHE_HOME/nvim/server.pipe"
+if ! [ -e "$server_pipe" ]; then
+ nohup nvim --listen "$server_pipe" --headless >/dev/null 2>&1 &
+fi
+
(
- if ! [ -e "$server_pipe" ]; then
- nohup nvim --listen "$server_pipe" --headless >/dev/null 2>&1 &
+ file_names=()
+ if [ -n "$1" ]; then
+ for file_name in "${@}"; do
+ if [[ "${file_name:0:1}" == / || "${file_name:0:2}" == ~[/a-zA-Z0-9] ]]
+ then
+ file_names+=("$file_name")
+ else
+ file_names+=("${PWD}/$file_name")
+ fi
+ done
+ echo "got file_names: ${file_names[*]}"
fi
- if nvim --headless --server ~/.cache/nvim/server.pipe --remote-expr 'luaeval("vim.json.encode(vim.iter(vim.api.nvim_list_uis()):map(function(v) return v.chan end):totable())")' \
- | jq -r '.[]' \
- | while read -r chan; do
- osascript -e 'display notification "already existing ui('"$chan"')..." with title "vremote"'
- exit 1
- done
+ if ! nvim \
+ --headless \
+ --server ~/.cache/nvim/server.pipe \
+ --remote-expr 'luaeval("vim.json.encode(vim.iter(vim.api.nvim_list_uis()):map(function(v) return v.chan end):totable())")' \
+ | jq -er '.[]'
then
- if [ -n "$1" ]; then
- file_names=()
- for file_name in "${@}"; do
- if [[ "${file_name:0:1}" == / || "${file_name:0:2}" == ~[/a-zA-Z0-9] ]]
- then
- file_names+=("$file_name")
- else
- file_names+=("${PWD}/$file_name")
- fi
- done
- echo "got file_names: ${file_names[*]}"
- nvim --server "$server_pipe" --remote "${file_names[@]}" >/dev/tty
- fi
+ nvim --server "$server_pipe" --remote "${file_names[@]}" >/dev/tty
exec nvim --server "$server_pipe" --remote-ui >/dev/tty
+ else
+ if ! command -v osascript >/dev/null 2>&1; then
+ notify-send "already existing ui
+starting new nvim instance"
+ else
+ osascript -e 'display notification "already existing ui..." with title "vremote"'
+ fi
+ exec nvim "${file_names[@]}" >/dev/tty </dev/tty
fi
) > ~/vremote_logs 2>&1
diff --git a/mut/dwm b/mut/dwm
-Subproject 2133b7633e0ebaa6ee07bac9dd49016d84889b2
+Subproject 04c767c276cf4bbdd9bfdb6d2e8e05a1ca2909a
diff --git a/mut/lf/cleaner b/mut/lf/cleaner
index 1b18195..9513d38 100755
--- a/mut/lf/cleaner
+++ b/mut/lf/cleaner
@@ -1,2 +1,6 @@
#!/bin/sh
-exec kitten icat --clear --stdin no --transfer-mode file < /dev/null > /dev/tty
+if [ -n "$FIFO_UEBERZUG" ]; then
+ printf '{"action": "remove", "identifier": "PREVIEW"}\n' > "$FIFO_UEBERZUG"
+else
+ exec kitten icat --clear --stdin no --transfer-mode file < /dev/null > /dev/tty
+fi
diff --git a/mut/lf/scope b/mut/lf/scope
index 5571d42..57c0ed9 100755
--- a/mut/lf/scope
+++ b/mut/lf/scope
@@ -8,6 +8,8 @@ IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"
image() {
if [ -f "$1" ] && command -V kitten >/dev/null 2>&1; then
kitten icat --transfer-mode file --stdin no --place "${2}x${3}@${4}x${5}" "$1" < /dev/null > /dev/tty
+ elif [ -f "$1" ] && [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1; then
+ printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$4" "$5" "$(($2-1))" "$(($3-1))" "$1" > "$FIFO_UEBERZUG"
else
mediainfo "$6"
fi
diff --git a/mut/neovim/fnl/conf/init.fnl b/mut/neovim/fnl/conf/init.fnl
index 3e39450..05fbdac 100644
--- a/mut/neovim/fnl/conf/init.fnl
+++ b/mut/neovim/fnl/conf/init.fnl
@@ -115,6 +115,10 @@
:path "~/Sync/my/notes"}]}))
+(do
+ (local fzf (require "fzf-lua"))
+ ((. fzf "register_ui_select")))
+
(vim.api.nvim_create_user_command
:NixEdit
(fn [{: args}]
@@ -122,8 +126,6 @@
(vim.cmd (.. "e " (f:read))))
{:nargs 1})
-;; I like to use the qf to run a lot of stuff that prints junk
-;; Here I just check if ansi control stuff is printed and reparse the lines with efm
(local qf
(fn [{: id : title}]
(fn [lines]
diff --git a/mut/neovim/fnl/conf/pkgs/oil.fnl b/mut/neovim/fnl/conf/pkgs/oil.fnl
index 7845b79..284b8bd 100644
--- a/mut/neovim/fnl/conf/pkgs/oil.fnl
+++ b/mut/neovim/fnl/conf/pkgs/oil.fnl
@@ -1,4 +1,5 @@
(local oil (require :oil))
+(local fzf (require :fzf-lua))
(oil.setup
{
@@ -22,7 +23,7 @@
"<C-s>" "actions.select_vsplit"
"<C-h>" "actions.select_split"
"<C-t>" "actions.select_tab"
- "<C-p>" "actions.preview"
+ "<C-p>" #(fzf.files)
"<C-c>" "actions.close"
"<C-l>" "actions.refresh"
"." "actions.open_cmdline"
diff --git a/mut/st b/mut/st
-Subproject e0b285014d599ac4ee60f5d905884d8c6bb85ad
+Subproject d0cddd9c9e004f794c3bc5d63b1bf1ef7d964ef