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 --- .bash_profile | 2 +- .config/mango/config.conf | 12 +++++------ scripts/checkgit | 15 -------------- scripts/dafny | 8 -------- scripts/focus-sway | 10 --------- scripts/get-brightness-percentage | 5 ----- scripts/getprojects | 7 ------- scripts/git-ps1 | 9 --------- scripts/graphical-startup | 6 ------ scripts/killemacs | 5 ----- scripts/launchemacs | 5 ----- scripts/lock_computer | 4 ---- scripts/newemacs | 14 ------------- scripts/open-emacs | 12 ----------- scripts/open-emacs-project | 28 ------------------------- scripts/pause-idle | 2 -- scripts/record | 18 ----------------- scripts/restartemacs | 3 --- scripts/screenshot | 20 ------------------ scripts/sleep_computer | 3 --- scripts/start-idle | 2 -- scripts/start-xdg-portal-hyprland | 12 ----------- scripts/sysinfo | 37 ---------------------------------- scripts/system/git-ps1 | 9 +++++++++ scripts/system/graphical-startup | 7 +++++++ scripts/system/lock-computer | 4 ++++ scripts/system/monitor-battery | 30 +++++++++++++++++++++++++++ scripts/system/screenshot | 20 ++++++++++++++++++ scripts/system/sleep-computer | 3 +++ scripts/system/sysinfo | 37 ++++++++++++++++++++++++++++++++++ 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 ++++++++ scripts/view-portage | 8 -------- scripts/yt-dla | 8 -------- scripts/yt-dlv | 8 -------- 47 files changed, 261 insertions(+), 256 deletions(-) delete mode 100755 scripts/checkgit delete mode 100755 scripts/dafny delete mode 100755 scripts/focus-sway delete mode 100755 scripts/get-brightness-percentage delete mode 100755 scripts/getprojects delete mode 100755 scripts/git-ps1 delete mode 100755 scripts/graphical-startup delete mode 100755 scripts/killemacs delete mode 100755 scripts/launchemacs delete mode 100755 scripts/lock_computer delete mode 100755 scripts/newemacs delete mode 100755 scripts/open-emacs delete mode 100755 scripts/open-emacs-project delete mode 100755 scripts/pause-idle delete mode 100755 scripts/record delete mode 100755 scripts/restartemacs delete mode 100755 scripts/screenshot delete mode 100755 scripts/sleep_computer delete mode 100755 scripts/start-idle delete mode 100755 scripts/start-xdg-portal-hyprland delete mode 100755 scripts/sysinfo create mode 100755 scripts/system/git-ps1 create mode 100755 scripts/system/graphical-startup create mode 100755 scripts/system/lock-computer create mode 100755 scripts/system/monitor-battery create mode 100755 scripts/system/screenshot create mode 100755 scripts/system/sleep-computer create mode 100755 scripts/system/sysinfo 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 delete mode 100755 scripts/view-portage delete mode 100755 scripts/yt-dla delete mode 100755 scripts/yt-dlv diff --git a/.bash_profile b/.bash_profile index ba43ca0..62995cf 100644 --- a/.bash_profile +++ b/.bash_profile @@ -3,7 +3,7 @@ if [ -f "$HOME/.bashrc" ]; then fi # Environment Variables -export PATH="$HOME/dotfiles/scripts/:$PATH" +export PATH="$HOME/dotfiles/scripts/util:$HOME/dotfiles/scripts/system:$PATH" export EDITOR="/bin/emacs" # Create XDG Runtime Dir diff --git a/.config/mango/config.conf b/.config/mango/config.conf index 64cd298..8eb275b 100644 --- a/.config/mango/config.conf +++ b/.config/mango/config.conf @@ -151,8 +151,8 @@ bind=SUPER,r,reload_config bind=SUPER,Return,spawn,swenu-run bind=SUPER,w,spawn,librewolf bind=SUPER,a,spawn,foot -bind=SUPER+CTRL,l,spawn,lock_computer -bind=SUPER+SHIFT+CTRL,l,spawn,sleep_computer +bind=SUPER+CTRL,l,spawn,lock-computer +bind=SUPER+SHIFT+CTRL,l,spawn,sleep-computer bind=SUPER,i,spawn,sysinfo # volume binds @@ -246,10 +246,10 @@ bind=ALT+SHIFT,Z,incgaps,-1 bind=ALT+SHIFT,R,togglegaps # movewin -bind=CTRL+SHIFT,Up,movewin,+0,-50 -bind=CTRL+SHIFT,Down,movewin,+0,+50 -bind=CTRL+SHIFT,Left,movewin,-50,+0 -bind=CTRL+SHIFT,Right,movewin,+50,+0 +# bind=CTRL+SHIFT,Up,movewin,+0,-50 +# bind=CTRL+SHIFT,Down,movewin,+0,+50 +# bind=CTRL+SHIFT,Left,movewin,-50,+0 +# bind=CTRL+SHIFT,Right,movewin,+50,+0 # resizewin bind=CTRL+ALT,Up,resizewin,+0,-50 diff --git a/scripts/checkgit b/scripts/checkgit deleted file mode 100755 index 985433a..0000000 --- a/scripts/checkgit +++ /dev/null @@ -1,15 +0,0 @@ -#!/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/dafny b/scripts/dafny deleted file mode 100755 index 93b26a7..0000000 --- a/scripts/dafny +++ /dev/null @@ -1,8 +0,0 @@ -#!/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/focus-sway b/scripts/focus-sway deleted file mode 100755 index e3c63fb..0000000 --- a/scripts/focus-sway +++ /dev/null @@ -1,10 +0,0 @@ -#!/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/get-brightness-percentage b/scripts/get-brightness-percentage deleted file mode 100755 index 1cb19ca..0000000 --- a/scripts/get-brightness-percentage +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -brightness=$(brightnessctl g) -max_brightness=$(brightnessctl m) -brightness_percentage=$(( ($brightness - 1) * 100 / ($max_brightness - 1) )) -echo "$brightness_percentage%" diff --git a/scripts/getprojects b/scripts/getprojects deleted file mode 100755 index 3f0bd31..0000000 --- a/scripts/getprojects +++ /dev/null @@ -1,7 +0,0 @@ -#!/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/git-ps1 b/scripts/git-ps1 deleted file mode 100755 index 0b860cd..0000000 --- a/scripts/git-ps1 +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -out=$(git branch --show-current 2>/dev/null) -if [ -z "$out" ] ; then - out="" -else - out="($out) " -fi -echo -n "$out" - diff --git a/scripts/graphical-startup b/scripts/graphical-startup deleted file mode 100755 index 877ca59..0000000 --- a/scripts/graphical-startup +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# pipewire & -dunst & -swaybg -i $HOME/dotfiles/files/wallpapers/mill.png & -swayidle timeout 300 sleep_computer & -# restartemacs >/dev/null & diff --git a/scripts/killemacs b/scripts/killemacs deleted file mode 100755 index 1228018..0000000 --- a/scripts/killemacs +++ /dev/null @@ -1,5 +0,0 @@ -#!/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/launchemacs b/scripts/launchemacs deleted file mode 100755 index 8b95242..0000000 --- a/scripts/launchemacs +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -name=$(ls -1 $XDG_RUNTIME_DIR/emacs/ | swenu -ceoil 10 -p "Workspace:") -if [ $? -eq 0 ]; then - emacsclient -c -s "$name" -fi diff --git a/scripts/lock_computer b/scripts/lock_computer deleted file mode 100755 index 0abb3a2..0000000 --- a/scripts/lock_computer +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -if not pgrep swaylock; then - swaylock -fi diff --git a/scripts/newemacs b/scripts/newemacs deleted file mode 100755 index 6b7052c..0000000 --- a/scripts/newemacs +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -project_name=$(swenu -coil 10 -p "New Workspace:") -if [ $? -ne 0 ]; then - exit 1 -fi - -project_path=$(getprojects | swenu -coil 10 -p "Directory:" -s "$project_name") - -emacs --daemon="$project_name" -if [ -z "$project_path" ]; then - emacsclient -c -s "$project_name" -else - emacsclient -c -s "$project_name" -e "(dired \"$project_path\")" -fi diff --git a/scripts/open-emacs b/scripts/open-emacs deleted file mode 100755 index 2f63efd..0000000 --- a/scripts/open-emacs +++ /dev/null @@ -1,12 +0,0 @@ -#!/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/open-emacs-project b/scripts/open-emacs-project deleted file mode 100755 index 48360b1..0000000 --- a/scripts/open-emacs-project +++ /dev/null @@ -1,28 +0,0 @@ -#!/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/pause-idle b/scripts/pause-idle deleted file mode 100755 index fa7e317..0000000 --- a/scripts/pause-idle +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -pkill -x hypridle diff --git a/scripts/record b/scripts/record deleted file mode 100755 index c061b5e..0000000 --- a/scripts/record +++ /dev/null @@ -1,18 +0,0 @@ -#!/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/restartemacs b/scripts/restartemacs deleted file mode 100755 index 7f2cee4..0000000 --- a/scripts/restartemacs +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -pkill -x emacs -emacs --daemon diff --git a/scripts/screenshot b/scripts/screenshot deleted file mode 100755 index b599be2..0000000 --- a/scripts/screenshot +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -echo $1 -echo $2 - -if [[ $1 == "-full" ]]; -then - if [[ $2 == "-save" ]]; - then - grim -o eDP-1 ~/Pictures/Screenshots/$(date +'%s_grim.png') - else - grim -o eDP-1 - | wl-copy - fi -else - if [[ $1 == "-save" ]]; - then - grim -g "$(slurp)" ~/Pictures/Screenshots/$(date +'%s_grim.png') - else - grim -g "$(slurp)" - | wl-copy - fi -fi diff --git a/scripts/sleep_computer b/scripts/sleep_computer deleted file mode 100755 index 5a62465..0000000 --- a/scripts/sleep_computer +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -echo "mem" | doas tee /sys/power/state -lock_computer diff --git a/scripts/start-idle b/scripts/start-idle deleted file mode 100755 index f16b66a..0000000 --- a/scripts/start-idle +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -hypridle diff --git a/scripts/start-xdg-portal-hyprland b/scripts/start-xdg-portal-hyprland deleted file mode 100755 index 80a17dd..0000000 --- a/scripts/start-xdg-portal-hyprland +++ /dev/null @@ -1,12 +0,0 @@ -#!/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/sysinfo b/scripts/sysinfo deleted file mode 100755 index 5cb2d07..0000000 --- a/scripts/sysinfo +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -get_message() { - - # Date - echo "Date: $(date +"%a %b %d")" - echo "Time: $(date +"%I:%M:%S")" - - # Volume - echo "$(wpctl get-volume @DEFAULT_SINK@ | awk -F' ' '{ printf "%s %s%% %s", $1, ($2 * 100), $3; }')" - - # Brightness - echo "Brightness: $(brightnessctl -m | cut -d, -f 4)" - - # Battery - echo "$(cat /sys/class/power_supply/BAT0/status): $(cat /sys/class/power_supply/BAT0/capacity)%" - - # Network Info - net_device=$(ip a | grep "state UP" | awk -F': ' '{ printf($2) }') - case "${net_device}" in - wlan*) - connected_network=$(iwctl station ${net_device} show | grep 'Connected network' \ - | awk -F' ' '{ printf($3) }') - ;; - eth*) - ;; - esac - echo "${net_device}: ${connected_network}" -} - -message=$(get_message) - -if [ "$TERM" = "linux" ]; then - notify-send "System Info" "$message" -else - echo "$message" -fi diff --git a/scripts/system/git-ps1 b/scripts/system/git-ps1 new file mode 100755 index 0000000..0b860cd --- /dev/null +++ b/scripts/system/git-ps1 @@ -0,0 +1,9 @@ +#!/bin/sh +out=$(git branch --show-current 2>/dev/null) +if [ -z "$out" ] ; then + out="" +else + out="($out) " +fi +echo -n "$out" + diff --git a/scripts/system/graphical-startup b/scripts/system/graphical-startup new file mode 100755 index 0000000..52bbb8b --- /dev/null +++ b/scripts/system/graphical-startup @@ -0,0 +1,7 @@ +#!/bin/sh +# pipewire & +dunst & +swaybg -i $HOME/dotfiles/files/wallpapers/mill.png & +swayidle timeout 300 sleep-computer & +monitor-battery & +# restartemacs >/dev/null & diff --git a/scripts/system/lock-computer b/scripts/system/lock-computer new file mode 100755 index 0000000..0abb3a2 --- /dev/null +++ b/scripts/system/lock-computer @@ -0,0 +1,4 @@ +#!/bin/sh +if not pgrep swaylock; then + swaylock +fi diff --git a/scripts/system/monitor-battery b/scripts/system/monitor-battery new file mode 100755 index 0000000..94b7365 --- /dev/null +++ b/scripts/system/monitor-battery @@ -0,0 +1,30 @@ +#!/bin/sh + +threshold=20 +very_low_threshold=10 + +amount="low" +prev_cap=100 + +while true; do + cap=$(cat /sys/class/power_supply/BAT0/capacity) + status=$(cat /sys/class/power_supply/BAT0/status) + + # when capacity changes + if [ $cap -ne $prev_cap ]; then + + # notify when drop under threshold + if [ $cap -lt $threshold ] && [ $prev_cap -ge $threshold ]; then + notify-send "Plug In" "Battery has fallen under $threshold%" + fi + + # notify every percent if very low + if [ $cap -le $very_low_threshold ] && [ $status -ne "Charging" ]; then + notify-send "BATTERY LOW" "Battery is at $bat%" + fi + + fi + + prev_cap=$cap + sleep 10 +done diff --git a/scripts/system/screenshot b/scripts/system/screenshot new file mode 100755 index 0000000..b599be2 --- /dev/null +++ b/scripts/system/screenshot @@ -0,0 +1,20 @@ +#!/bin/bash +echo $1 +echo $2 + +if [[ $1 == "-full" ]]; +then + if [[ $2 == "-save" ]]; + then + grim -o eDP-1 ~/Pictures/Screenshots/$(date +'%s_grim.png') + else + grim -o eDP-1 - | wl-copy + fi +else + if [[ $1 == "-save" ]]; + then + grim -g "$(slurp)" ~/Pictures/Screenshots/$(date +'%s_grim.png') + else + grim -g "$(slurp)" - | wl-copy + fi +fi diff --git a/scripts/system/sleep-computer b/scripts/system/sleep-computer new file mode 100755 index 0000000..e7768d8 --- /dev/null +++ b/scripts/system/sleep-computer @@ -0,0 +1,3 @@ +#!/bin/sh +echo "mem" | doas tee /sys/power/state +lock-computer diff --git a/scripts/system/sysinfo b/scripts/system/sysinfo new file mode 100755 index 0000000..5cb2d07 --- /dev/null +++ b/scripts/system/sysinfo @@ -0,0 +1,37 @@ +#!/bin/sh + +get_message() { + + # Date + echo "Date: $(date +"%a %b %d")" + echo "Time: $(date +"%I:%M:%S")" + + # Volume + echo "$(wpctl get-volume @DEFAULT_SINK@ | awk -F' ' '{ printf "%s %s%% %s", $1, ($2 * 100), $3; }')" + + # Brightness + echo "Brightness: $(brightnessctl -m | cut -d, -f 4)" + + # Battery + echo "$(cat /sys/class/power_supply/BAT0/status): $(cat /sys/class/power_supply/BAT0/capacity)%" + + # Network Info + net_device=$(ip a | grep "state UP" | awk -F': ' '{ printf($2) }') + case "${net_device}" in + wlan*) + connected_network=$(iwctl station ${net_device} show | grep 'Connected network' \ + | awk -F' ' '{ printf($3) }') + ;; + eth*) + ;; + esac + echo "${net_device}: ${connected_network}" +} + +message=$(get_message) + +if [ "$TERM" = "linux" ]; then + notify-send "System Info" "$message" +else + echo "$message" +fi 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 diff --git a/scripts/view-portage b/scripts/view-portage deleted file mode 100755 index f2fcb00..0000000 --- a/scripts/view-portage +++ /dev/null @@ -1,8 +0,0 @@ -#!/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/yt-dla b/scripts/yt-dla deleted file mode 100755 index f87f145..0000000 --- a/scripts/yt-dla +++ /dev/null @@ -1,8 +0,0 @@ -#!/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/yt-dlv b/scripts/yt-dlv deleted file mode 100755 index 6b96b4e..0000000 --- a/scripts/yt-dlv +++ /dev/null @@ -1,8 +0,0 @@ -#!/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