summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xbin/dots4
-rwxr-xr-xbin/equery-fuzzy16
-rwxr-xr-xbin/git-sync38
-rwxr-xr-xbin/grimshot15
-rwxr-xr-xbin/ntfm38
-rwxr-xr-xbin/screenrec28
6 files changed, 139 insertions, 0 deletions
diff --git a/bin/dots b/bin/dots
index cee0d73..7076ece 100755
--- a/bin/dots
+++ b/bin/dots
@@ -25,4 +25,8 @@ push)
 	$0 git push inazuma || true
 	$0 git push origin || true
 	;;
+untracked)
+	shift
+	exec $0 git ls-files -o $*
+	;;
 esac
diff --git a/bin/equery-fuzzy b/bin/equery-fuzzy
new file mode 100755
index 0000000..1f0202a
--- /dev/null
+++ b/bin/equery-fuzzy
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -eu
+rel="equery list -f -op -F '[\$location] \$category/\$name-\$fullversion::\$repo' {q} || :"
+opn="echo {2}"
+pre="equery -N meta {2} && hr && equery -N uses {2}"
+exec fzf --layout=reverse --height='~60%' \
+	--disabled \
+	--ansi \
+	--query "${1:-portage}" \
+	--accept-nth="2" \
+	--preview="$pre" \
+	--preview-window=down,wrap \
+	--bind=start:reload:"$rel" \
+	--bind=change:reload:"$rel" \
+	--bind=tab:replace-query \
+	--bind=enter:replace-query+become:"$opn"
diff --git a/bin/git-sync b/bin/git-sync
new file mode 100755
index 0000000..b18c94d
--- /dev/null
+++ b/bin/git-sync
@@ -0,0 +1,38 @@
+#!/bin/bash
+set -eu
+[ -n "${DEBUG:-}" ] && set -x
+
+# use cli arg
+base_branch=${1:-}
+
+# detect base branch (when git-new was used)
+[ -n "$base_branch" ] || base_branch=$(git symbolic-ref --short refs/bases/"$(git symbolic-ref --short HEAD)" 2>/dev/null || :)
+
+# detect trunk via origin/HEAD
+[ -n "$base_branch" ] || base_branch=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null || :)
+
+# fallback to base branch => current branch
+[ -n "$base_branch" ] || base_branch=$(git symbolic-ref --short HEAD 2>/dev/null || :)
+
+# resolve upstream
+if [[ "$base_branch" = "origin/"* ]]; then
+	upstream=$base_branch
+else
+	upstream=$(git rev-parse --abbrev-ref --symbolic-full-name "$base_branch"'@{u}')
+fi
+
+[ -n "${base_branch:?}" ] || exit 1
+[ -n "${upstream:?}" ] || exit 1
+
+echo "Syncing with $upstream (base: $base_branch)"
+
+# fetch upstream
+git fetch ${upstream/\// }
+
+# check if base and upstream have diverged
+if ! git diff --quiet "$upstream" "$base_branch"; then
+	git diff --stat "$upstream" "$base_branch"
+fi
+
+# rebase
+git rebase --interactive "$upstream"
diff --git a/bin/grimshot b/bin/grimshot
new file mode 100755
index 0000000..b946c27
--- /dev/null
+++ b/bin/grimshot
@@ -0,0 +1,15 @@
+#!/bin/sh
+set -eu
+
+screenshot_dir=$XDG_PICTURES_DIR/screenshots
+screenshot_path=$screenshot_dir/"$(date --iso-8601=seconds).png"
+
+mkdir -p $screenshot_dir || exit 1
+
+grim -g "$(slurp)" "$screenshot_path" || exit 1
+
+wl-copy --type image/png < "$screenshot_path" || exit 1
+
+wl-copy --primary "$screenshot_path" || exit 1
+
+fyi -a grimshot -i "$screenshot_path" "grimshot" "$screenshot_path"
diff --git a/bin/ntfm b/bin/ntfm
new file mode 100755
index 0000000..dd7344f
--- /dev/null
+++ b/bin/ntfm
@@ -0,0 +1,38 @@
+#!/bin/bash
+set -eu
+
+# shellcheck disable=2034
+description="notification manager"
+
+FUZL_PROMPT=ntfm
+. libfuzl.sh
+
+main() {
+	local nid
+
+	nid=$(makoctl list |
+		awk '/Notification/{match($0,/[0-9]+/); print substr($0,RSTART,RLENGTH) "\t" substr($0,RSTART+RLENGTH+1)}' |
+		fuzl_menu $FUZL_MENU_FILTER --with-nth=2 --accept-nth=1 --no-run-if-empty)
+	[ -n "$nid" ] || return
+
+	fuzl_action_add menu "󰮫" "open menu"
+	fuzl_action_add dismiss "󰅗" "dimiss"
+	fuzl_action_menu "$nid"
+}
+
+#
+# actions
+#
+
+ntfm_menu() {
+	local nid=${1:?}
+	exec makoctl menu -n "$nid" -- fuzzel -d
+}
+
+ntfm_dismiss() {
+	local nid=${1:?}
+	exec makoctl dismiss -n "$nid"
+}
+
+
+main
diff --git a/bin/screenrec b/bin/screenrec
new file mode 100755
index 0000000..5324ead
--- /dev/null
+++ b/bin/screenrec
@@ -0,0 +1,28 @@
+#!/bin/sh
+set -eu
+
+update_waybar() {
+	sleep .5
+	pkill -RTMIN+1 -x waybar
+}
+
+trap '{ update_waybar & disown; }' SIGCHLD EXIT
+
+if [ "${1:-}" = "stop" ]; then
+	exec pkill -HUP -x wl-screenrec
+fi
+
+screengrab_dir=$XDG_VIDEOS_DIR/screengrabs
+screengrab_path=$screengrab_dir/"$(date --iso-8601=seconds).mkv"
+
+mkdir -p $screengrab_dir || exit 1
+
+output=$(slurp -b '#000000aa' -c '#4E437188' -w 50 -f '%o' -or)
+
+update_waybar & disown
+
+wl-screenrec --filename="$screengrab_path" --output="$output" $@ || true
+
+wl-copy "$screengrab_path"
+
+fyi -a screenrec "screenrec" "$screengrab_path"