From 28903f80785bd17489ad844bd9f8a86451422474 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Sun, 28 Sep 2025 10:04:15 -0400 Subject: [PATCH] feat: Moves local scripts directory. Handles systemd configurations. --- dev-env | 24 ++- .../systemd}/user/battery-monitor.service | 2 +- .../systemd}/user/battery-monitor.timer | 0 .../.config/systemd}/user/logout-task.service | 2 +- {scripts => env/.local}/scripts/ask-gpt | 0 env/.local/scripts/battery-monitor | 32 ++++ env/.local/scripts/clear-clipboard-history | 8 + env/.local/scripts/close-all-windows | 5 + {scripts => env/.local}/scripts/haasd | 0 {scripts => env/.local}/scripts/haasp | 0 {scripts => env/.local}/scripts/haasz | 0 {scripts => env/.local}/scripts/hcpn | 0 {scripts => env/.local}/scripts/hxzet | 0 env/.local/scripts/install-webapp | 151 ++++++++++++++++++ {scripts => env/.local}/scripts/isosec | 0 env/.local/scripts/launch-webapp | 7 + {scripts => env/.local}/scripts/mhlink | 0 {scripts => env/.local}/scripts/mkhpadir | 0 {scripts => env/.local}/scripts/mktrans | 0 .../scripts/mv-all-workspaces-to-monitor | 15 ++ {scripts => env/.local}/scripts/ncis | 0 {scripts => env/.local}/scripts/newx | 0 {scripts => env/.local}/scripts/nvims | 0 {scripts => env/.local}/scripts/path | 0 {scripts => env/.local}/scripts/pzet | 0 {scripts => env/.local}/scripts/termcolors | 0 .../.local}/scripts/tmux-sessionator | 0 env/.local/scripts/toggle-desktop | 29 ++++ env/.local/scripts/toggle-internal-monitor | 12 ++ env/.local/scripts/toggle-waybar | 11 ++ {scripts => env/.local}/scripts/urlencode | 0 .../.local}/scripts/vault-gopass-client | 0 env/.local/scripts/waybar-restart | 4 + env/.local/scripts/window-toggle-floating | 27 ++++ env/.zshenv | 2 +- scripts/arch/lid.sh | 20 --- scripts/scripts/allfigl | 12 -- scripts/scripts/banner | 8 - scripts/scripts/clean-derived-data | 9 -- scripts/scripts/cmt | 8 - scripts/scripts/duck | 5 - scripts/scripts/figl | 16 -- scripts/scripts/link_apps | 58 ------- scripts/scripts/post-to-facebook | 94 ----------- scripts/scripts/uncmt | 8 - .../user/default.target.wants/espanso.service | 1 - systemd/user/espanso.service | 11 -- .../hypridle.service | 1 - .../hyprpaper.service | 1 - systemd/user/hypr-lid.service | 11 -- 50 files changed, 323 insertions(+), 271 deletions(-) rename {systemd => env/.config/systemd}/user/battery-monitor.service (73%) rename {systemd => env/.config/systemd}/user/battery-monitor.timer (100%) rename {systemd => env/.config/systemd}/user/logout-task.service (74%) rename {scripts => env/.local}/scripts/ask-gpt (100%) create mode 100755 env/.local/scripts/battery-monitor create mode 100755 env/.local/scripts/clear-clipboard-history create mode 100755 env/.local/scripts/close-all-windows rename {scripts => env/.local}/scripts/haasd (100%) rename {scripts => env/.local}/scripts/haasp (100%) rename {scripts => env/.local}/scripts/haasz (100%) rename {scripts => env/.local}/scripts/hcpn (100%) rename {scripts => env/.local}/scripts/hxzet (100%) create mode 100755 env/.local/scripts/install-webapp rename {scripts => env/.local}/scripts/isosec (100%) create mode 100755 env/.local/scripts/launch-webapp rename {scripts => env/.local}/scripts/mhlink (100%) rename {scripts => env/.local}/scripts/mkhpadir (100%) rename {scripts => env/.local}/scripts/mktrans (100%) create mode 100755 env/.local/scripts/mv-all-workspaces-to-monitor rename {scripts => env/.local}/scripts/ncis (100%) rename {scripts => env/.local}/scripts/newx (100%) rename {scripts => env/.local}/scripts/nvims (100%) rename {scripts => env/.local}/scripts/path (100%) rename {scripts => env/.local}/scripts/pzet (100%) rename {scripts => env/.local}/scripts/termcolors (100%) rename {scripts => env/.local}/scripts/tmux-sessionator (100%) create mode 100755 env/.local/scripts/toggle-desktop create mode 100755 env/.local/scripts/toggle-internal-monitor create mode 100755 env/.local/scripts/toggle-waybar rename {scripts => env/.local}/scripts/urlencode (100%) rename {scripts => env/.local}/scripts/vault-gopass-client (100%) create mode 100755 env/.local/scripts/waybar-restart create mode 100755 env/.local/scripts/window-toggle-floating delete mode 100755 scripts/arch/lid.sh delete mode 100755 scripts/scripts/allfigl delete mode 100755 scripts/scripts/banner delete mode 100755 scripts/scripts/clean-derived-data delete mode 100755 scripts/scripts/cmt delete mode 100755 scripts/scripts/duck delete mode 100755 scripts/scripts/figl delete mode 100755 scripts/scripts/link_apps delete mode 100755 scripts/scripts/post-to-facebook delete mode 100755 scripts/scripts/uncmt delete mode 120000 systemd/user/default.target.wants/espanso.service delete mode 100644 systemd/user/espanso.service delete mode 120000 systemd/user/graphical-session.target.wants/hypridle.service delete mode 120000 systemd/user/graphical-session.target.wants/hyprpaper.service delete mode 100644 systemd/user/hypr-lid.service diff --git a/dev-env b/dev-env index ea4b11d..a297cbf 100755 --- a/dev-env +++ b/dev-env @@ -31,11 +31,13 @@ log() { log "env: $DEV_ENV" +# Removes a destination directory and copies all files to the destination. update_files() { log "copying over files from: $1" pushd $1 &>/dev/null ( - configs=$(find . -mindepth 1 -maxdepth 1 -type d) + # Copy everything except systemd folder, it needs treated differently. + configs=$(find . -mindepth 1 -maxdepth 1 -name "systemd" -prune -o -type d -print) for c in $configs; do directory=${2%/}/${c#./} log " removing: rm -rf $directory" @@ -54,6 +56,7 @@ update_files() { popd &>/dev/null } +# Removes a destination file and copies a single file to the destination. copy() { log "removing: $2" if [[ $dry_run == "0" ]]; then @@ -65,16 +68,27 @@ copy() { fi } +# Copy all files from a directory into another directory. +copy_files() { + for f in $(find $1 -mindepth 1 -maxdepth 1 -type f); do + copy $f "$2/$(basename $f)" + done +} + update_files $DEV_ENV/env/.config $XDG_CONFIG_HOME update_files $DEV_ENV/env/.local $HOME/.local -# + +# Systemd. +mkdir -p $XDG_CONFIG_HOME/systemd/user +copy_files $DEV_ENV/env/.config/systemd/user $XDG_CONFIG_HOME/systemd/user + # copy $DEV_ENV/tmux-sessionizer/tmux-sessionizer $HOME/.local/scripts/tmux-sessionizer copy $DEV_ENV/env/.zshenv $HOME/.zshenv copy $DEV_ENV/env/.tmux.conf $HOME/.tmux.conf +# GPG mkdir $HOME/.gnupg -rm $HOME/.gnupg/gpg.conf >/dev/null 1>&2 && copy $DEV_ENV/env/.gnupg/gpg.conf $HOME/.gnupg/gpg.conf -rm $HOME/.gnupg/gpg-agent.conf >/dev/null 1>&2 && copy $DEV_ENV/env/.gnupg/gpg-agent.conf $HOME/.gnupg/gpg-agent.conf -rm $HOME/.gnupg/scdaemon.conf >/dev/null 1>&2 && copy $DEV_ENV/env/.gnupg/scdaemon.conf $HOME/.gnupg/scdaemon.conf +copy_files $DEV_ENV/env/.gnupg $HOME/.gnupg +systemctl --user daemon-reload hyprctl reload diff --git a/systemd/user/battery-monitor.service b/env/.config/systemd/user/battery-monitor.service similarity index 73% rename from systemd/user/battery-monitor.service rename to env/.config/systemd/user/battery-monitor.service index 0b0cdcb..07e824e 100644 --- a/systemd/user/battery-monitor.service +++ b/env/.config/systemd/user/battery-monitor.service @@ -4,5 +4,5 @@ After=graphical-session.target [Service] Type=oneshot -ExecStart=%h/.local/bin/battery-monitor +ExecStart=%h/.local/scripts/battery-monitor Environment=DISPLAY=:0 diff --git a/systemd/user/battery-monitor.timer b/env/.config/systemd/user/battery-monitor.timer similarity index 100% rename from systemd/user/battery-monitor.timer rename to env/.config/systemd/user/battery-monitor.timer diff --git a/systemd/user/logout-task.service b/env/.config/systemd/user/logout-task.service similarity index 74% rename from systemd/user/logout-task.service rename to env/.config/systemd/user/logout-task.service index ae59b93..97fce73 100644 --- a/systemd/user/logout-task.service +++ b/env/.config/systemd/user/logout-task.service @@ -5,7 +5,7 @@ Before=exit.target [Service] Type=oneshot -ExecStart=%h/.local/bin/clear-clipboard-history +ExecStart=%h/.local/scripts/clear-clipboard-history [Install] WantedBy=exit.target diff --git a/scripts/scripts/ask-gpt b/env/.local/scripts/ask-gpt similarity index 100% rename from scripts/scripts/ask-gpt rename to env/.local/scripts/ask-gpt diff --git a/env/.local/scripts/battery-monitor b/env/.local/scripts/battery-monitor new file mode 100755 index 0000000..8909589 --- /dev/null +++ b/env/.local/scripts/battery-monitor @@ -0,0 +1,32 @@ +#!/bin/zsh + +# Used with the systemd battery monitor service and timer to alert +# when the battery has dropped below the threshold and is not currently +# charging. + +THRESHOLD=20 # Notify when below 20% +NOTIFICATION_FLAG="/run/user/${UID}/user_battery_notified" + +function get-battery-percentage() { + local battery=$(upower --battery | grep percentage) + echo "${battery//[^0-9]/}" +} + +function send-battery-alert() { + notify-send -u critical \ + "Recharge battery!" "Batttery is down to ${1}" \ + -i battery-caution \ + -t 30000 +} + +battery_percentage=$(get-battery-percentage) +battery_state=$(upower --battery | grep -E state | awk '{print $2}') + +if [[ "$battery_state" == "discharging" && "$battery_percentage" -le "$THRESHOLD" ]]; then + if [ ! -f "$NOTIFICATION_FLAG" ]; then + send-battery-alert "$battery_percentage" + touch "$NOTIFICATION_FLAG" + fi +else + rm -f "$NOTIFICATION_FLAG" +fi diff --git a/env/.local/scripts/clear-clipboard-history b/env/.local/scripts/clear-clipboard-history new file mode 100755 index 0000000..057bebf --- /dev/null +++ b/env/.local/scripts/clear-clipboard-history @@ -0,0 +1,8 @@ +#!/bin/bash + +#wl-copy --clear >/dev/null 2>&1 && \ +if [ -n "$WAYLAND_DISPLAY" ]; then + wl-copy --clear +fi + +rm ~/.local/share/clipse/clipboard_history.json >/dev/null 2>&1 diff --git a/env/.local/scripts/close-all-windows b/env/.local/scripts/close-all-windows new file mode 100755 index 0000000..8e64b99 --- /dev/null +++ b/env/.local/scripts/close-all-windows @@ -0,0 +1,5 @@ +#!/bin/bash + +hyprctl clients -j | \ + jq '.[] | .address' | \ + xargs -I{} hyprctl dispatch closewindow address:{} diff --git a/scripts/scripts/haasd b/env/.local/scripts/haasd similarity index 100% rename from scripts/scripts/haasd rename to env/.local/scripts/haasd diff --git a/scripts/scripts/haasp b/env/.local/scripts/haasp similarity index 100% rename from scripts/scripts/haasp rename to env/.local/scripts/haasp diff --git a/scripts/scripts/haasz b/env/.local/scripts/haasz similarity index 100% rename from scripts/scripts/haasz rename to env/.local/scripts/haasz diff --git a/scripts/scripts/hcpn b/env/.local/scripts/hcpn similarity index 100% rename from scripts/scripts/hcpn rename to env/.local/scripts/hcpn diff --git a/scripts/scripts/hxzet b/env/.local/scripts/hxzet similarity index 100% rename from scripts/scripts/hxzet rename to env/.local/scripts/hxzet diff --git a/env/.local/scripts/install-webapp b/env/.local/scripts/install-webapp new file mode 100755 index 0000000..3831fb5 --- /dev/null +++ b/env/.local/scripts/install-webapp @@ -0,0 +1,151 @@ +#!/bin/zsh + +# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file + +function usage() { + cat <] [-u ] [-i ] [-e ] [-m ] [-h] [args...] + +OPTIONS: + -n | --name: The name of the application. + -u | --url: The url used to launch the application. + -i | --icon: The icon for the application. + -e | --exec: Custom execution command (optional). + -m | --mime-types: MIME-types for the application (optional). + -h | --help: Show usage information. + +EXAMPLES: + +If no options or arguments are supplied, then it will start an interactive session that prompts for the +values. + + $ install-webapp + +Calling the app with named arguments: + + $ install-webapp \\ + --name "My Awesome App" \\ + --url "https://awesome.com" \\ + --icon "https://awesome.com/assets/icon.png" + +It is also possible to use only positional arguments with out their key. They can be passed in the order as +they're listed. + + $ install-webapp "My Awesome App" \\ + "https://awesome.com" \\ + "https://awesome.com/assets/icon.png" + +NOTES: + +The icon option can either be a url where we will download a png from or a local file. Local files +can either be the full path to the file or a file name of an icon located in '~/.local/share/applications/icons/'. + +Interactive sessions do not give the option to use a custom execution command or supply the +MIME types, which are less frequently used options. + +EOF +} + +declare -a app_name +declare -a app_url +declare -a icon_ref +declare -a custom_exec # Optional custom exec command +declare -a mime_types # Optional mime types +declare -a help_flag +declare INTERACTIVE_MODE=false + +zparseopts -D -F -K -- \ + {n,-name}:=app_name \ + {u,-url}:=app_url \ + {i,-icon}:=icon_ref \ + {e,-exec}:=custom_exec \ + {m,-mime-types}:=mime_types \ + {h,-help}=help_flag + +[ ${#help_flag[@]} -gt 0 ] && usage && exit 0 + +# If passed in as positional arguments, without flags. +[ -n "$1" ] && app_name+=("$1") +[ -n "$2" ] && app_url+=("$2") +[ -n "$3" ] && icon_ref+=("$3") +[ -n "$4" ] && custom_exec+=("$4") +[ -n "$5" ] && mime_types+=("$5") + +# Check if proper arguments were passed in. Start interactive mode if not. +if [[ -z "$app_name[-1]" || -z "$app_url[-1]" || -z "$icon_ref[-1]" ]]; then + echo -e "\e[32mLet's create a new web app you can start with the app launcher.\n\e[0m" + app_name+=($(gum input --prompt "Name> " --placeholder "My favorite web app")) + app_url+=($(gum input --prompt "URL> " --placeholder "https://example.com")) + icon_ref+=($(gum input --prompt "Icon URL> " --placeholder "See https://dashboardicons.com (must use PNG!)")) + INTERACTIVE_MODE=true +else + INTERACTIVE_MODE=false +fi + +# Ensure valid execution +if [[ -z "$app_name[-1]" || -z "$app_url[-1]" || -z "$icon_ref[-1]" ]]; then + echo "You must set app name, app URL, and icon URL!" + exit 1 +fi + +APP_NAME=$app_name[-1] +APP_URL=$app_url[-1] +ICON_REF=$icon_ref[-1] +CUSTOM_EXEC=$custom_exec[-1] +MIME_TYPES=$mime_types[-1] + +# Refer to local icon or fetch remotely from URL +ICON_DIR="$HOME/.local/share/applications/icons" +if [[ $ICON_REF == https://* ]]; then + ICON_PATH="$ICON_DIR/$APP_NAME.png" + if curl -sL -o "$ICON_PATH" "$ICON_REF"; then + ICON_PATH="$ICON_DIR/$APP_NAME.png" + else + echo "Error: Failed to download icon." + exit 1 + fi +else + # Check if the icon path is a file. + if [ -f $ICON_REF ]; then + ICON_PATH=$ICON_REF + else + ICON_PATH="$ICON_DIR/$ICON_REF" + fi +fi + +# Use custom exec if provided, otherwise default behavior +if [[ -n $CUSTOM_EXEC ]]; then + EXEC_COMMAND="$CUSTOM_EXEC" +else + EXEC_COMMAND="$HOME/.local/bin/launch-webapp $APP_URL" +fi + +# Create application .desktop file +DESKTOP_FILE="$HOME/.local/share/applications/$APP_NAME.desktop" + +cat >"$DESKTOP_FILE" <>"$DESKTOP_FILE" +fi + +chmod +x "$DESKTOP_FILE" + +if [[ $INTERACTIVE_MODE == true ]]; then + echo -e "You can now find $APP_NAME using the app launcher (SUPER + SPACE)\n" +fi diff --git a/scripts/scripts/isosec b/env/.local/scripts/isosec similarity index 100% rename from scripts/scripts/isosec rename to env/.local/scripts/isosec diff --git a/env/.local/scripts/launch-webapp b/env/.local/scripts/launch-webapp new file mode 100755 index 0000000..842ec4e --- /dev/null +++ b/env/.local/scripts/launch-webapp @@ -0,0 +1,7 @@ +#!/bin/bash + +# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file +# +browser="chromium.desktop" + +exec setsid uwsm app -- $(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,~/.nix-profile,/usr}/share/applications/$browser 2>/dev/null | head -1) --app="$1" "${@:2}" diff --git a/scripts/scripts/mhlink b/env/.local/scripts/mhlink similarity index 100% rename from scripts/scripts/mhlink rename to env/.local/scripts/mhlink diff --git a/scripts/scripts/mkhpadir b/env/.local/scripts/mkhpadir similarity index 100% rename from scripts/scripts/mkhpadir rename to env/.local/scripts/mkhpadir diff --git a/scripts/scripts/mktrans b/env/.local/scripts/mktrans similarity index 100% rename from scripts/scripts/mktrans rename to env/.local/scripts/mktrans diff --git a/env/.local/scripts/mv-all-workspaces-to-monitor b/env/.local/scripts/mv-all-workspaces-to-monitor new file mode 100755 index 0000000..b956969 --- /dev/null +++ b/env/.local/scripts/mv-all-workspaces-to-monitor @@ -0,0 +1,15 @@ +#!/bin/bash + +# Moves all workspaces to the passed in monitor id, which can be useful when +# connecting or disconnecting from a monitor. + +MONITOR=$1 + +if [ ! $# = 1 ]; then + echo "Usage: mv-all-workspaces-to-monitor " + exit 1 +fi + +hyprctl workspaces -j | + jq '.[] | select(.monitorID != "$MONITOR") | .id' | + xargs -I{} hyprctl dispatch moveworkspacetomonitor {} "$MONITOR" >/dev/null 2>&1 diff --git a/scripts/scripts/ncis b/env/.local/scripts/ncis similarity index 100% rename from scripts/scripts/ncis rename to env/.local/scripts/ncis diff --git a/scripts/scripts/newx b/env/.local/scripts/newx similarity index 100% rename from scripts/scripts/newx rename to env/.local/scripts/newx diff --git a/scripts/scripts/nvims b/env/.local/scripts/nvims similarity index 100% rename from scripts/scripts/nvims rename to env/.local/scripts/nvims diff --git a/scripts/scripts/path b/env/.local/scripts/path similarity index 100% rename from scripts/scripts/path rename to env/.local/scripts/path diff --git a/scripts/scripts/pzet b/env/.local/scripts/pzet similarity index 100% rename from scripts/scripts/pzet rename to env/.local/scripts/pzet diff --git a/scripts/scripts/termcolors b/env/.local/scripts/termcolors similarity index 100% rename from scripts/scripts/termcolors rename to env/.local/scripts/termcolors diff --git a/scripts/scripts/tmux-sessionator b/env/.local/scripts/tmux-sessionator similarity index 100% rename from scripts/scripts/tmux-sessionator rename to env/.local/scripts/tmux-sessionator diff --git a/env/.local/scripts/toggle-desktop b/env/.local/scripts/toggle-desktop new file mode 100755 index 0000000..13787a3 --- /dev/null +++ b/env/.local/scripts/toggle-desktop @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Workspace to hide everything in +HIDE_WS="special:hidden" + +# File to store original workspace ID +STATE_FILE="/tmp/hypr_hide_state" + +# Get current workspace ID +CUR_WS=$(hyprctl -j activeworkspace | jq -r '.id') + +# Check if we're currently hidden +if [[ -f "$STATE_FILE" ]]; then + # Restore windows + ORIG_WS=$(cat "$STATE_FILE") + for win in $(hyprctl -j clients | jq -r ".[] | select(.workspace.name | contains(\"$HIDE_WS\")) | .address"); do + hyprctl dispatch movetoworkspace "$ORIG_WS,address:$win" + hyprctl dispatch workspace "$ORIG_WS" + done + rm "$STATE_FILE" +else + # Hide all windows (move to special hidden workspace) + for win in $(hyprctl -j clients | jq -r ".[] | select(.workspace.id == $CUR_WS) | .address"); do + hyprctl dispatch movetoworkspace "$HIDE_WS,address:$win" + hyprctl dispatch togglespecialworkspace "$HIDE_WS" + done + rm "$STATE_FILE" + echo "$CUR_WS" >"$STATE_FILE" +fi diff --git a/env/.local/scripts/toggle-internal-monitor b/env/.local/scripts/toggle-internal-monitor new file mode 100755 index 0000000..f645e3e --- /dev/null +++ b/env/.local/scripts/toggle-internal-monitor @@ -0,0 +1,12 @@ +#!/bin/zsh +# +# Toggles the state of the internal laptop monitor, which is useful +# when I'm connected to an external monitor / docks. + +monitor="eDP-1" + +if hyprctl monitors | grep -q "$monitor"; then + hyprctl keyword monitor "$monitor,disable" 1>/dev/null +else + hyprctl keyword monitor "$monitor,enable" 1>/dev/null +fi diff --git a/env/.local/scripts/toggle-waybar b/env/.local/scripts/toggle-waybar new file mode 100755 index 0000000..d2a8cda --- /dev/null +++ b/env/.local/scripts/toggle-waybar @@ -0,0 +1,11 @@ +#!/bin/sh + +WAYBAR_PID=$(pgrep -x waybar) + +if [ -n "$WAYBAR_PID" ]; then + # kill waybar process if it's running. + kill "$WAYBAR_PID" +else + # start waybar in the background. + waybar & +fi diff --git a/scripts/scripts/urlencode b/env/.local/scripts/urlencode similarity index 100% rename from scripts/scripts/urlencode rename to env/.local/scripts/urlencode diff --git a/scripts/scripts/vault-gopass-client b/env/.local/scripts/vault-gopass-client similarity index 100% rename from scripts/scripts/vault-gopass-client rename to env/.local/scripts/vault-gopass-client diff --git a/env/.local/scripts/waybar-restart b/env/.local/scripts/waybar-restart new file mode 100755 index 0000000..a93feb1 --- /dev/null +++ b/env/.local/scripts/waybar-restart @@ -0,0 +1,4 @@ +#!/bin/zsh + +pkill -x waybar +setsid uwsm app -- waybar >/dev/null 2>&1 & diff --git a/env/.local/scripts/window-toggle-floating b/env/.local/scripts/window-toggle-floating new file mode 100755 index 0000000..1a5f35c --- /dev/null +++ b/env/.local/scripts/window-toggle-floating @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Float's a window, setting it's height and width and centering. + +# The percentage of the screen size for the floating window. +WIDTH_PERCENT=80 +HEIGHT_PERCENT=40 + +floating=$(hyprctl activewindow -j | jq '.floating') + +if [ "$floating" = "true" ]; then + hyprctl dispatch togglefloating +else + monitor=$(hyprctl monitors -j | jq '.[] | select(.focused == true)') + mw=$(echo "$monitor" | jq '.width') + mh=$(echo "$monitor" | jq '.height') + ms=$(echo "$monitor" | jq '.scale') + + echo "scale: $ms" + + neww=$(echo "scale=6; (($mw / $ms) * $WIDTH_PERCENT / 100)" | bc) + newh=$(echo "scale=6; (($mh / $ms) * $HEIGHT_PERCENT / 100)" | bc) + + hyprctl dispatch togglefloating && + hyprctl dispatch resizeactive exact $neww $newh && + hyprctl dispatch centerwindow +fi diff --git a/env/.zshenv b/env/.zshenv index 4e3a285..c7c3422 100755 --- a/env/.zshenv +++ b/env/.zshenv @@ -47,7 +47,7 @@ export NAP_CONFIG="$HOME/.config/nap/config.yaml" export PDFS="$HOME/Library/Mobile Documents/com~apple~Preview/Documents" export PROPOSALS="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work/Proposals" export SCREENSHOTS="$BUCKET/Pictures/Screenshots" -export SCRIPTS="$XDG_DATA_HOME/scripts" +export SCRIPTS="$$HOME/.local/scripts" export SITES="$GHREPOS/sites" export SKELETONDIR="$DOTFILES/skeleton" export WORK="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work" diff --git a/scripts/arch/lid.sh b/scripts/arch/lid.sh deleted file mode 100755 index 11f26ba..0000000 --- a/scripts/arch/lid.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -INTERNAL="eDP-1" # check with `hyprctl monitors` - -# Check lid event handler with: -# -# grep -A5 -i lid /proc/bus/input/devices -# -# The event is contained in the H: Handlers=kbd event -# -DEVICE="/dev/input/event0" # replace with your lid event device - -evtest --grab "$DEVICE" | - while read -r line; do - if echo "$line" | grep -q "SW_LID.*value 1"; then - hyprctl keyword monitor "$INTERNAL,disable" - elif echo "$line" | grep -q "SW_LID.*value 0"; then - hyprctl keyword monitor "$INTERNAL,preferred,auto,auto" - fi - done diff --git a/scripts/scripts/allfigl b/scripts/scripts/allfigl deleted file mode 100755 index 8520565..0000000 --- a/scripts/scripts/allfigl +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -font_dir="$(brew --prefix)/share/figlet/fonts" - -for font in "${font_dir}"/*.flf; do - clear - echo "FONT: $font" - figlet -f "${font}" hello - read -r line -done diff --git a/scripts/scripts/banner b/scripts/scripts/banner deleted file mode 100755 index a6f5341..0000000 --- a/scripts/scripts/banner +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -set -e - -message="${1:-m-housh}" -font="${2:-puffy}" - -echo "${message}" | figlet -c -f "${font}" diff --git a/scripts/scripts/clean-derived-data b/scripts/scripts/clean-derived-data deleted file mode 100755 index 1d4687e..0000000 --- a/scripts/scripts/clean-derived-data +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -if [ "$(uname -n)" = "Michaels-Mac-mini.local" ]; then - echo "Removing derived data folders" - rm -r /Volumes/Bucket/Library/Developer/Xcode/DerivedData -else - echo "Removing derived data folders" - rm -r ~/Library/Developer/Xcode/DerivedData/* -fi diff --git a/scripts/scripts/cmt b/scripts/scripts/cmt deleted file mode 100755 index 01b18ab..0000000 --- a/scripts/scripts/cmt +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/zsh - -# adapted from... -# https://github.com/rwxrob/dot/blob/main/scripts/cmt - -while IFS= read -r line; do - echo "${1:-#} $line" -done diff --git a/scripts/scripts/duck b/scripts/scripts/duck deleted file mode 100755 index ddb6be9..0000000 --- a/scripts/scripts/duck +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -url="https://lite.duckduckgo.com/lite?kd=1&kp=1&q=$(urlencode "$*")" - -exec lynx -vikeys "$url" diff --git a/scripts/scripts/figl b/scripts/scripts/figl deleted file mode 100755 index 3a78237..0000000 --- a/scripts/scripts/figl +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Create a new figlet (ascii art) from the input. - -figl() { - font=${FIGL_FONT:-puffy} - declare -a buf - while IFS= read -r line; do - buf+=("$line") - done - for line in "${buf[@]}"; do - figlet -f "$font" -c "${line}" | head -6 - done -} - -figl "$*" diff --git a/scripts/scripts/link_apps b/scripts/scripts/link_apps deleted file mode 100755 index 6b8c488..0000000 --- a/scripts/scripts/link_apps +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh - -# Creates symlinks from external application directory -# to another directory so applications are seen in -# spotlight searches and launchpad. - -set -e - -app_dir="" -destination_dir="" - -# Parses the input arguments. If 2 arguments are passed in, then -# the first is where we search for applications (source) and the second -# argument is the destination directory for the symlinks to be placed in -# -# If one argument is passed in, then it is used as the destination directory -# and we use the default source directory. -_parse_args() { - arg_count="$#" - app_dir="/Volumes/M1 Mac-Mini External Drive/Applications" - destination_dir="${HOME}/Application" - if test "$arg_count" -eq 1; then - destination_dir="$1" - elif test "$arg_count" -eq 2; then - app_dir="$1" - destination_dir="$2" - fi -} - -# Checks if the `app_dir` exists. -_is_mounted() { - if ! test -d "$app_dir"; then - echo "Application directory does not exist or is not mounted" >&2 - return 1 - fi -} - -# ---------------- main ------------------- - -main() { - - _parse_args "$@" - test -d "${destination_dir}" || echo "Destination does not exist" >&2 - - if test _is_mounted; then - for app in "${app_dir}"/*.app; do - destination="${destination_dir}/$(basename "${app}")" - if test -e "${destination}"; then - echo "Destination already exists: ${destination}. Skipping!" >&2 - continue - fi - # remove echo to do real work. - echo ln -sv "${app}" "${destination}" >&2 - done - fi -} - -main "$@" diff --git a/scripts/scripts/post-to-facebook b/scripts/scripts/post-to-facebook deleted file mode 100755 index f103379..0000000 --- a/scripts/scripts/post-to-facebook +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env zsh - -# Posts to facebook group and personal page. -# -# Typical usage would be to generate a link to the latest -# blog post and send to facebook: -# -# `$ mhlink --last | xargs -I {} post-to-facebook -m {}` -# -# - -#################### Options #################### -declare -a message - -zparseopts -D -F -K -- \ - {a,-all}=locationOpt \ - {m,-message}+:=message \ - {o,-offline}=offline \ - {p,-personal}=locationOpt \ - {h,-help}=help - -baseUrl="https://graph.facebook.com/v18.0" -link=$1 -message="${message[-1]}" -token=$(cat < "$HOME/.config/facebook-bot/access-token.txt") - -#################### Usage #################### -function usage() { - cat <" - -Usage: post-to-facebook [-a] [-m ] [-o] [-p] - - -a | --all: Send the post to the group and personal pages. - -m | --message: The optional message. - -o | --offline: Do not send the request(s), but print them. - -p | --personal: Send to personal page only. - -h | --help: Show the usage. - -The -a or -p options are optional, if neither is supplied then it will -only be posted to the group. - -EOF -} - -#################### Helpers #################### - -function post() { - local url=$1 - if [ -n "$offline" ]; then - echo "Offline mode, request not being sent." - http --offline --ignore-stdin POST "$url" access_token=="$token" \ - link="$link" \ - message="$message" - else - http --ignore-stdin POST "$url" access_token=="$token" \ - link="$link" \ - message="$message" - fi -} - -function post_to_group() { - group=$(cat < "$HOME/.config/facebook-bot/group.txt") - post "$baseUrl/$group/feed" -} - -function post_to_personal() { - post "$baseUrl/me/feed" -} - -#################### Main #################### - -[ -n "$help" ] && usage && exit 0 - -[ -z "$link" ] && [ -z "$message" ] \ - && echo "Link or message is required." \ - && exit 1 - -[ "$locationOpt" = "-p" ] || [ "$locationOpt" = "--personal" ] \ - && post_to_personal \ - && exit 0 - -[ "$locationOpt" = "-a" ] || [ "$locationOpt" = "--all" ] \ - && post_to_personal - -post_to_group - diff --git a/scripts/scripts/uncmt b/scripts/scripts/uncmt deleted file mode 100755 index ff1c646..0000000 --- a/scripts/scripts/uncmt +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# adapted from... -# https://github.com/rwxrob/dot/blob/main/scripts/ucmt - -while IFS= read -r line; do - echo "${line#* }" -done diff --git a/systemd/user/default.target.wants/espanso.service b/systemd/user/default.target.wants/espanso.service deleted file mode 120000 index f839101..0000000 --- a/systemd/user/default.target.wants/espanso.service +++ /dev/null @@ -1 +0,0 @@ -/home/michael/.config/systemd/user/espanso.service \ No newline at end of file diff --git a/systemd/user/espanso.service b/systemd/user/espanso.service deleted file mode 100644 index 6c30d4a..0000000 --- a/systemd/user/espanso.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=espanso - -[Service] -ExecStart=/usr/bin/espanso launcher -Restart=on-failure -RestartSec=3 - -[Install] -WantedBy=default.target - diff --git a/systemd/user/graphical-session.target.wants/hypridle.service b/systemd/user/graphical-session.target.wants/hypridle.service deleted file mode 120000 index 55da293..0000000 --- a/systemd/user/graphical-session.target.wants/hypridle.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/user/hypridle.service \ No newline at end of file diff --git a/systemd/user/graphical-session.target.wants/hyprpaper.service b/systemd/user/graphical-session.target.wants/hyprpaper.service deleted file mode 120000 index a5b7405..0000000 --- a/systemd/user/graphical-session.target.wants/hyprpaper.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/user/hyprpaper.service \ No newline at end of file diff --git a/systemd/user/hypr-lid.service b/systemd/user/hypr-lid.service deleted file mode 100644 index c6e2247..0000000 --- a/systemd/user/hypr-lid.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Hyprland lid handler using evdev -After=graphical.target - -[Service] -ExecStart=%h/.local/bin/lid.sh -Restart=always - -[Install] -WantedBy=default.target -