summaryrefslogtreecommitdiff
path: root/scripts/util
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2026-05-15 22:36:21 -0400
committerJack Jamison <jackqjamison@gmail.com>2026-05-15 22:36:21 -0400
commit1c58ccb7855719483490abe1982afa12b0488f24 (patch)
treed6d6f95477c743c1e2e8f4a64095d50cb491338c /scripts/util
parentfbe17d51cc2d52261721a46ee54d5dc8f32db3eb (diff)
refactor and battery notifier
Diffstat (limited to 'scripts/util')
-rwxr-xr-xscripts/util/checkgit15
-rwxr-xr-xscripts/util/dafny8
-rwxr-xr-xscripts/util/focus-sway10
-rwxr-xr-xscripts/util/getprojects7
-rwxr-xr-xscripts/util/killemacs5
-rwxr-xr-xscripts/util/open-emacs12
-rwxr-xr-xscripts/util/open-emacs-project28
-rwxr-xr-xscripts/util/record18
-rwxr-xr-xscripts/util/restartemacs3
-rwxr-xr-xscripts/util/start-idle2
-rwxr-xr-xscripts/util/start-xdg-portal-hyprland12
-rwxr-xr-xscripts/util/view-portage8
-rwxr-xr-xscripts/util/yt-dla8
-rwxr-xr-xscripts/util/yt-dlv8
14 files changed, 144 insertions, 0 deletions
diff --git a/scripts/util/checkgit b/scripts/util/checkgit
new file mode 100755
index 0000000..985433a
--- /dev/null
+++ b/scripts/util/checkgit
@@ -0,0 +1,15 @@
+#!/bin/bash
+# script checks all git repositories in subdirectory and displays their uncommitted changes
+
+echo -e ""
+for dir in *; do
+ if [[ -d $dir ]] then
+ if [[ -d "$dir/.git" ]] then
+ gStatus=$(git -c color.ui=always -C $dir status -s)
+ if [[ -n $gStatus ]] then
+ echo $dir
+ echo -e "${gStatus}\n"
+ fi
+ fi
+ fi
+done
diff --git a/scripts/util/dafny b/scripts/util/dafny
new file mode 100755
index 0000000..93b26a7
--- /dev/null
+++ b/scripts/util/dafny
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# get args
+file="${!#}"
+set -- "${@:1:$(($#-1))}"
+args="$@"
+
+cat "$file" | ssh vm "tee ~/dafny/torun.dfy > /dev/null; dafny $args ~/dafny/torun.dfy"
diff --git a/scripts/util/focus-sway b/scripts/util/focus-sway
new file mode 100755
index 0000000..e3c63fb
--- /dev/null
+++ b/scripts/util/focus-sway
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# Get available windows
+windows=$(swaymsg -t get_tree | jq -r '.nodes[1].nodes[].nodes[] | .. | (.id|tostring) + " " + .name?' | grep -e "[0-9]* ." )
+
+# Select window with rofi
+selected=$(echo "$windows" | swenu -coil 10 | awk '{print $1}')
+
+# Tell sway to focus said window
+swaymsg [con_id="$selected"] focus
diff --git a/scripts/util/getprojects b/scripts/util/getprojects
new file mode 100755
index 0000000..3f0bd31
--- /dev/null
+++ b/scripts/util/getprojects
@@ -0,0 +1,7 @@
+#!/bin/sh
+{
+ find "$HOME/homework/" -mindepth 2 -maxdepth 2 -type d
+ find "$HOME/development/" -mindepth 1 -maxdepth 1 -type d
+ find "$HOME/opt/" -mindepth 1 -maxdepth 1 -type d
+ find "$HOME/classes/" -mindepth 1 -maxdepth 1 -type d
+}
diff --git a/scripts/util/killemacs b/scripts/util/killemacs
new file mode 100755
index 0000000..1228018
--- /dev/null
+++ b/scripts/util/killemacs
@@ -0,0 +1,5 @@
+#!/bin/sh
+name=$(ls -1 $XDG_RUNTIME_DIR/emacs/ | swenu -ceoil 10 -p "Kill:")
+if [ $? -eq 0 ]; then
+ emacsclient -c -s "$name" -e '(kill-emacs)'
+fi
diff --git a/scripts/util/open-emacs b/scripts/util/open-emacs
new file mode 100755
index 0000000..2f63efd
--- /dev/null
+++ b/scripts/util/open-emacs
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+emacs_attached() {
+ [ "$(emacsclient -e '(- (length (frame-list)) 1)')" = 0 ] && return 1 || return 0
+}
+
+if emacs_attached; then
+ # focus emacs
+ swaymsg [con_id="$(swaymsg -t get_tree | jq -r '.nodes[1].nodes[].nodes[] | .. | (.id|tostring) + " " + .app_id?' | grep emacs | awk '{print $1}')"] focus
+else
+ emacsclient -c
+fi
diff --git a/scripts/util/open-emacs-project b/scripts/util/open-emacs-project
new file mode 100755
index 0000000..48360b1
--- /dev/null
+++ b/scripts/util/open-emacs-project
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+find_dirs() {
+ echo $(emacsclient -e "(proj--get-paths)" | sed -ze 's/(\(.*\))/\1/') | xargs -n1
+}
+
+emacs_attached() {
+ [ "$(emacsclient -e '(- (length (frame-list)) 1)')" = 0 ] && return 1 || return 0
+}
+
+switch_to() {
+ if emacs_attached; then
+ emacsclient -e "(proj-set \"$1\")"
+ else
+ emacsclient -ce "(proj-set \"$1\")"
+ fi
+}
+
+# get selected
+selected=$(find_dirs | swenu -coil 15)
+[ -z "$selected" ] && exit 1;
+selected="${selected/\~/$HOME}"
+
+# set emacs project
+switch_to "$selected"
+
+# focus emacs
+swaymsg [con_id="$(swaymsg -t get_tree | jq -r '.nodes[1].nodes[].nodes[] | .. | (.id|tostring) + " " + .app_id?' | grep emacs | awk '{print $1}')"] focus
diff --git a/scripts/util/record b/scripts/util/record
new file mode 100755
index 0000000..c061b5e
--- /dev/null
+++ b/scripts/util/record
@@ -0,0 +1,18 @@
+#!/bin/env bash
+
+pgrep -x "wf-recorder" && pkill -INT -x wf-recorder && exit 0
+
+# notify-send -h string:wf-recorder:record -t 1000 "Recording in:" "<span color='#90a4f4' font='26px'><i><b>3</b></i></span>"
+
+# sleep 1
+
+# notify-send -h string:wf-recorder:record -t 1000 "Recording in:" "<span color='#90a4f4' font='26px'><i><b>2</b></i></span>"
+
+# sleep 1
+
+# notify-send -h string:wf-recorder:record -t 950 "Recording in:" "<span color='#90a4f4' font='26px'><i><b>1</b></i></span>"
+
+# sleep 1
+
+dateTime=$(date +%m-%d-%Y-%H:%M:%S)
+wf-recorder --bframes max_b_frames -f $HOME/Videos/$dateTime.mp4
diff --git a/scripts/util/restartemacs b/scripts/util/restartemacs
new file mode 100755
index 0000000..7f2cee4
--- /dev/null
+++ b/scripts/util/restartemacs
@@ -0,0 +1,3 @@
+#!/bin/sh
+pkill -x emacs
+emacs --daemon
diff --git a/scripts/util/start-idle b/scripts/util/start-idle
new file mode 100755
index 0000000..f16b66a
--- /dev/null
+++ b/scripts/util/start-idle
@@ -0,0 +1,2 @@
+#!/bin/sh
+hypridle
diff --git a/scripts/util/start-xdg-portal-hyprland b/scripts/util/start-xdg-portal-hyprland
new file mode 100755
index 0000000..80a17dd
--- /dev/null
+++ b/scripts/util/start-xdg-portal-hyprland
@@ -0,0 +1,12 @@
+#!/bin/sh
+sleep 1
+killall xdg-desktop-portal-hyprland
+killall xdg-desktop-portal-gnome
+killall xdg-desktop-portal-wlr
+killall xdg-desktop-portal
+
+sleep 1
+/usr/libexec/xdg-desktop-portal-hyprland &
+
+sleep 2
+/usr/libexec/xdg-desktop-portal &
diff --git a/scripts/util/view-portage b/scripts/util/view-portage
new file mode 100755
index 0000000..f2fcb00
--- /dev/null
+++ b/scripts/util/view-portage
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+logs=$(for file in /var/tmp/portage/*/*; do
+ echo "$(basename $(dirname $file))/$(basename $file)"
+done)
+
+selected=$(echo "$logs" | swenu)
+doas less -R -f +F /var/tmp/portage/$selected/temp/build.log
diff --git a/scripts/util/yt-dla b/scripts/util/yt-dla
new file mode 100755
index 0000000..f87f145
--- /dev/null
+++ b/scripts/util/yt-dla
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+echo "$1"
+if [ -z "$1" ] ; then
+ echo "usage: $0 [url of youtube video]"
+ exit 1
+fi
+yt-dlp -x --audio-format mp3 --audio-quality 0 "$1"
diff --git a/scripts/util/yt-dlv b/scripts/util/yt-dlv
new file mode 100755
index 0000000..6b96b4e
--- /dev/null
+++ b/scripts/util/yt-dlv
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+echo "$1"
+if [ -z "$1" ] ; then
+ echo "usage: $0 [url of youtube video]"
+ exit 1
+fi
+yt-dlp "$1" \ No newline at end of file