From 1c58ccb7855719483490abe1982afa12b0488f24 Mon Sep 17 00:00:00 2001 From: Jack Jamison Date: Fri, 15 May 2026 22:36:21 -0400 Subject: refactor and battery notifier --- scripts/util/checkgit | 15 +++++++++++++++ scripts/util/dafny | 8 ++++++++ scripts/util/focus-sway | 10 ++++++++++ scripts/util/getprojects | 7 +++++++ scripts/util/killemacs | 5 +++++ scripts/util/open-emacs | 12 ++++++++++++ scripts/util/open-emacs-project | 28 ++++++++++++++++++++++++++++ scripts/util/record | 18 ++++++++++++++++++ scripts/util/restartemacs | 3 +++ scripts/util/start-idle | 2 ++ scripts/util/start-xdg-portal-hyprland | 12 ++++++++++++ scripts/util/view-portage | 8 ++++++++ scripts/util/yt-dla | 8 ++++++++ scripts/util/yt-dlv | 8 ++++++++ 14 files changed, 144 insertions(+) create mode 100755 scripts/util/checkgit create mode 100755 scripts/util/dafny create mode 100755 scripts/util/focus-sway create mode 100755 scripts/util/getprojects create mode 100755 scripts/util/killemacs create mode 100755 scripts/util/open-emacs create mode 100755 scripts/util/open-emacs-project create mode 100755 scripts/util/record create mode 100755 scripts/util/restartemacs create mode 100755 scripts/util/start-idle create mode 100755 scripts/util/start-xdg-portal-hyprland create mode 100755 scripts/util/view-portage create mode 100755 scripts/util/yt-dla create mode 100755 scripts/util/yt-dlv (limited to 'scripts/util') 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:" "3" + +# sleep 1 + +# notify-send -h string:wf-recorder:record -t 1000 "Recording in:" "2" + +# sleep 1 + +# notify-send -h string:wf-recorder:record -t 950 "Recording in:" "1" + +# 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 -- cgit v1.2.3