6 Commits

15 changed files with 528 additions and 272 deletions

View File

@@ -35,7 +35,7 @@ $housecallPro = https://pro.housecallpro.com/app/calendar_new
bindd = $mainMod, SPACE, Application launcher, exec, $menu bindd = $mainMod, SPACE, Application launcher, exec, $menu
bindd = $mainMod, RETURN, New terminal, exec, $terminal bindd = $mainMod, RETURN, New terminal, exec, $terminal
bindd = $mainMod SHIFT, RETURN, New floating terminal, exec, $terminal --class=com.ghostty.float bindd = $mainMod SHIFT, RETURN, New floating terminal, exec, $terminal --class=com.ghostty.float
bindd = $mainMod, TAB, Focus previous workspace, exec, $scripts/switch-to-workspace previous #workspace, previous bindd = $mainMod, TAB, Focus previous workspace, exec, $scripts/switch-to-workspace previous
bindd = $mainMod, A, [A]i - launch / focus, exec, $pwa --or-focus "https://chatgpt.com" bindd = $mainMod, A, [A]i - launch / focus, exec, $pwa --or-focus "https://chatgpt.com"
bindd = $mainMod SHIFT, A, [A]i - new window, exec, $pwa "https://chatgpt.com" bindd = $mainMod SHIFT, A, [A]i - new window, exec, $pwa "https://chatgpt.com"
bindd = $mainMod, B, New [b]rowser, exec, $browser bindd = $mainMod, B, New [b]rowser, exec, $browser
@@ -43,12 +43,13 @@ bindd = $mainMod SHIFT, B, New private [b]rowser, exec,
bindd = $mainMod, C, [C]alendar, exec, $pwa --or-focus "https://www.icloud.com/calendar" bindd = $mainMod, C, [C]alendar, exec, $pwa --or-focus "https://www.icloud.com/calendar"
bindd = $mainMod SHIFT, C, [C]onfig folder in tmux session, exec, $terminal -e $tmuxSessionator ~/.config bindd = $mainMod SHIFT, C, [C]onfig folder in tmux session, exec, $terminal -e $tmuxSessionator ~/.config
bindd = $mainMod, D, [D]ispatch app - special workspace, exec, $pwa --special dispatch $housecallPro bindd = $mainMod, D, [D]ispatch app - special workspace, exec, $pwa --special dispatch $housecallPro
bindd = $mainMod SHIFT, D, [D]ispatch app - new window, exec, $pwa --new-instance $housecallPro bindd = $mainMod SHIFT, D, [D]ispatch app - new window, exec, $pwa --new $housecallPro
bindd = $mainMod, E, [E]mail - personal, exec, $pwa --or-focus "https://mail.proton.me" bindd = $mainMod, E, [E]mail - personal, exec, $pwa --or-focus "https://mail.proton.me"
bindd = $mainMod SHIFT, E, [E]mail - work, exec, $scripts/launch --or-focus thunderbird uwsm app -- thunderbird bindd = $mainMod SHIFT, E, [E]mail - work, exec, $scripts/launch --or-focus thunderbird uwsm app -- thunderbird
bindd = $mainMod, F, [F]ile manager - terminal, exec, $fileManager bindd = $mainMod, F, [F]ile manager - terminal, exec, $fileManager
bindd = $mainMod SHIFT, F, [F]ile manager - application, exec, $fileBrowser bindd = $mainMod SHIFT, F, [F]ile manager - application, exec, $fileBrowser
bindd = $mainMod, G, [G]itea, exec, $pwa "https://git.housh.dev" bindd = $mainMod, G, [G]itea, exec, $pwa --or-focus "https://git.housh.dev"
bindd = $mainMod SHIFT, G, [G]ithub, exec, $pwa --or-focus "https://github.com"
bindd = $mainMod, H, Focus window - left, movefocus, l # move window focus using vim keys bindd = $mainMod, H, Focus window - left, movefocus, l # move window focus using vim keys
bindd = $mainMod SHIFT, H, Workspace - back, workspace, -1 bindd = $mainMod SHIFT, H, Workspace - back, workspace, -1
bindd = $mainMod, J, Focus window - down, movefocus, d # move window focus using vim keys bindd = $mainMod, J, Focus window - down, movefocus, d # move window focus using vim keys

View File

@@ -1,38 +1,47 @@
[ [
{ {
"name": "App - install web app", "name": "App - install web app",
"description": "Install a new website as a desktop application that can be launched by an application launcher.",
"exec": "$SCRIPTS/hypr/install-webapp" "exec": "$SCRIPTS/hypr/install-webapp"
}, },
{ {
"name": "App - uninstall desktop app", "name": "App - uninstall desktop app",
"description": "Uninstalls desktop applications and their icon, generally used for web\napplications.\n\nIf the app was installed through a package manager, then you should\nuse the package manager to uninstall the applciation.",
"exec": "$SCRIPTS/hypr/uninstall-desktop-app" "exec": "$SCRIPTS/hypr/uninstall-desktop-app"
}, },
{ {
"name": "Clipboard - clear history", "name": "Clipboard - clear history",
"exec": "$SCRIPTS/hypr/clear-clipboard-history && echo Done" "description": "Clear the clipboard history file.",
"exec": "$SCRIPTS/hypr/clear-clipboard-history --notify-complete"
}, },
{ {
"name": "Monitors - stats / picker", "name": "Monitors - stats / picker",
"description": "View information from hyprctl about currently connected monitors.",
"exec": "$SCRIPTS/hypr/monitor-picker" "exec": "$SCRIPTS/hypr/monitor-picker"
}, },
{ {
"name": "Waybar - restart", "name": "Waybar - restart",
"description": "Restart the menu bar application, useful when making changes to the configuration.",
"exec": "$SCRIPTS/hypr/waybarctl --restart" "exec": "$SCRIPTS/hypr/waybarctl --restart"
}, },
{ {
"name": "Waybar - toggle", "name": "Waybar - toggle",
"description": "Toggle the visibility of the menu bar.",
"exec": "$SCRIPTS/hypr/waybarctl --toggle" "exec": "$SCRIPTS/hypr/waybarctl --toggle"
}, },
{ {
"name": "Windows - window stats / picker", "name": "Windows - window stats / picker",
"exec": "$SCRIPTS/hypr/window-table" "description": "View information from hyprctl about all the current windows.\n\nAllows you to choose an action you would like to perform on the selected window.",
"exec": "$SCRIPTS/hypr/windowctl"
}, },
{ {
"name": "Windows - close ALL in active workspace", "name": "Windows - close in active workspace",
"description": "Close all windows in the currently active workspace.",
"exec": "$SCRIPTS/hypr/close-windows --active-workspace" "exec": "$SCRIPTS/hypr/close-windows --active-workspace"
}, },
{ {
"name": "Windows - close ALL in all workspaces", "name": "Windows - close ALL",
"description": "Close all windows in all workspaces.",
"exec": "$SCRIPTS/hypr/close-windows --all" "exec": "$SCRIPTS/hypr/close-windows --all"
} }
] ]

View File

@@ -1,8 +1,21 @@
#!/bin/bash #!/bin/bash
#wl-copy --clear >/dev/null 2>&1 && \ notify_flag="0"
if [ -n "$WAYLAND_DISPLAY" ]; then XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
while [[ $# -gt 0 ]]; do
if [[ $1 == "-n" ]] || [[ $1 == "--notify-complete" ]]; then
notify_flag="1"
fi
shift
done
if [[ -n "$WAYLAND_DISPLAY" ]]; then
wl-copy --clear wl-copy --clear
fi fi
rm ~/.local/share/clipse/clipboard_history.json >/dev/null 2>&1 rm $XDG_DATA_HOME/clipse/clipboard_history.json >/dev/null 2>&1
if [[ $notify_flag == "1" ]] && [[ -n "$WAYLAND_DISPLAY" ]]; then
notify-send --urgency=low --expire-time=3000 --app-name="Clipboard History" "✅ Cleared clipboard history"
fi

View File

@@ -1,7 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
THIS_FILE=${BASH_SOURCE[0]} THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename "$THIS_FILE") # Allows script name to be set when called from a parent script or defaults to filename.
THIS=${THIS:-$(basename "$THIS_FILE")}
usage() { usage() {
cat <<EOF cat <<EOF

View File

@@ -294,7 +294,7 @@ log "\e[032mCreating web app:\e[0m $desktop_file"
print_properties print_properties
if [[ $dry_run == "0" ]]; then if [[ $dry_run == "0" ]]; then
generate_file $desktop_file generate_file "$desktop_file"
fi fi
if [[ $interactive_mode == true ]] && [[ $dry_run == "0" ]]; then if [[ $interactive_mode == true ]] && [[ $dry_run == "0" ]]; then

View File

@@ -23,7 +23,7 @@ OPTIONS:
instance. instance.
-x | --close-active-only: Close only windows on active workspace matching the pattern. -x | --close-active-only: Close only windows on active workspace matching the pattern.
-s | --special <name>: Launch or toggle a special workspace. -s | --special <name>: Launch or toggle a special workspace.
-n | --new-instance: Launch a new instance of an application. -n | --new: Launch a new instance of an application.
-h | --help: Show this help page. -h | --help: Show this help page.
NOTES: NOTES:
@@ -73,7 +73,7 @@ while [[ $# -gt 0 ]]; do
close_flag="1" close_flag="1"
close_active_only_flag="1" close_active_only_flag="1"
action="closewindow" action="closewindow"
elif [[ $1 == "-n" ]] || [[ $1 == "--new-instance" ]]; then elif [[ $1 == "-n" ]] || [[ $1 == "--new" ]]; then
new_instance_flag="1" new_instance_flag="1"
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
usage && exit 0 usage && exit 0

View File

@@ -11,13 +11,14 @@ Utility for getting fzf preview data.
USAGE: USAGE:
$ $THIS <mode> <arg> $ $THIS [MODE] [ARG...]
MODES: MODES:
monitor: Get monitor data, arg is the monitor id. monitor <id>: Get monitor data.
window: Get window data, arg is the window address. window <address>: Get window data.
workspace: Get workspace data, arg is the workspace id. workspace <id>: Get workspace data.
utlis <name> <config>: Get utils-launcher data.
EOF EOF
} }
@@ -35,8 +36,8 @@ log() {
source "$SCRIPTS/hypr/logging" source "$SCRIPTS/hypr/logging"
setup-logging "$THIS" setup-logging "$THIS"
if [[ ! "${#@}" == "2" ]]; then if [[ ! ${#@} -ge 2 ]]; then
log --error "Unexpected argument count: ${#@}, expected: 2" log --error "Unexpected argument count: ${#@}, expected at least: 2"
usage && exit 1 usage && exit 1
fi fi
@@ -50,6 +51,16 @@ elif [[ $mode == "window" ]]; then
hyprctl clients -j | jq -C ".[] | select(.address == \"$arg\")" hyprctl clients -j | jq -C ".[] | select(.address == \"$arg\")"
elif [[ $mode == "workspace" ]]; then elif [[ $mode == "workspace" ]]; then
hyprctl workspaces -j | jq -C ".[] | select(.id == $arg)" hyprctl workspaces -j | jq -C ".[] | select(.id == $arg)"
elif [[ $mode == "utils" ]]; then
config="${3//\'/}"
if [[ ! -f $config ]]; then
log --error "No utility-launcher config found: $config"
exit 1
fi
desc=$(jq -C ".[] | select(.name == \"$arg\") | .description" $config)
exec=$(jq -C ".[] | select(.name == \"$arg\") | .exec" $config)
echo -e "\n${desc[@]}\n\n"
echo -e "\e[31mEXEC:\e[0m $exec\n"
else else
log --error "Unexpected mode: $mode" log --error "Unexpected mode: $mode"
usage && exit 1 usage && exit 1

View File

@@ -77,7 +77,7 @@ generate_rows() {
# Setup logging file and label. # Setup logging file and label.
source "$SCRIPTS/hypr/logging" source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS" setup-logging "$THIS"
if [[ -z $XDG_CONFIG_HOME ]]; then if [[ -z $XDG_CONFIG_HOME ]]; then
log "XDG_CONFIG_HOME not set" log "XDG_CONFIG_HOME not set"
@@ -91,12 +91,6 @@ if [[ -z $config_file ]]; then
config_file="$XDG_CONFIG_HOME/utils-launcher/config.json" config_file="$XDG_CONFIG_HOME/utils-launcher/config.json"
fi fi
if [[ -z $SCRIPTS ]]; then
log "SCRIPTS not set"
log "using ~/.local/scripts"
SCRIPTS=$HOME/.local/scripts
fi
if [[ $launch_flag == "1" ]]; then if [[ $launch_flag == "1" ]]; then
launch && exit 0 launch && exit 0
fi fi
@@ -108,14 +102,16 @@ fi
file_data=$(cat $config_file) file_data=$(cat $config_file)
# Setup colors before calling fzf. # Setup colors before calling fzf.
[[ -f $SCRIPTS/catppuccin-colors ]] && source $SCRIPTS/catppuccin-colors [[ -z ${FZF_DEFAULT_OPTS} ]] &&
[[ -f $SCRIPTS/catppuccin-colors ]] &&
source $SCRIPTS/catppuccin-colors
generate_rows "$file_data" generate_rows "$file_data"
sel=$( sel=$(
printf "%s\n" "${rows[@]}" | printf "%s\n" "${rows[@]}" |
fzf --style=full --footer="$(footer)" --with-nth=2 --delimiter='|' \ fzf --style=full --footer="$(footer)" --with-nth=2 --delimiter='|' \
--preview-label='[ Command ]' \ --preview-label='[ Command ]' \
--preview='printf "\nName: {2}\nExec: {1}"' --preview="$SCRIPTS/hypr/preview-stats utils {2} $config_file"
) )
log "Selection: $sel" log "Selection: $sel"

View File

@@ -0,0 +1,139 @@
#!/usr/bin/env bash
THIS_FILE=${BASH_SOURCE[0]}
LOG_LABEL=$(basename "$THIS_FILE")
# Allows script name to be set when called from a parent script or defaults to filename.
THIS=${THIS:-$LOG_LABEL}
usage() {
cat <<EOF
Close window(s) by address or pattern mode.
USAGE:
$ $THIS [OPTIONS] [MODE] [ARG...]
MODE:
--all: Close all windows in all workspaces, any arguments are ignored.
-a | --active-workspace: Close all windows in the active workspace, any arguments are ignored.
-c | --class: Close all windows whose class contains one of the passed arguments.
-s | --special: Close all windows in special workspaces whose name matches on of the
passed in arguments, or if no arguments are supplied then it will close
all windows in all special workspaces.
OPTIONS:
--dry-run
-h | --help: Show this help page.
NOTES:
If a mode is selected all arguments are treated for that mode, meaning only one mode
runs. It does not work to mix modes / arguments.
If no modes are supplied then arguments are assumed to be window addresses and we will
close all supplied window addresses.
EOF
}
active_workspace_flag="0"
all_flag="0"
class_flag="0"
dry_run_flag="0"
special_flag="0"
args=()
addresses=()
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
while [[ $# -gt 0 ]]; do
if [[ $1 =~ ^-a ]] || [[ $1 =~ ^--active-workspace ]]; then
active_workspace_flag="1"
elif [[ $1 =~ ^--all ]]; then
all_flag="1"
elif [[ $1 =~ ^-c ]] || [[ $1 =~ ^--class ]]; then
class_flag="1"
elif [[ $1 =~ ^--dry-run ]]; then
dry_run_flag="1"
elif [[ $1 =~ ^-h ]] || [[ $1 =~ ^--help ]]; then
usage && exit 0
elif [[ $1 =~ ^-s ]] || [[ $1 =~ ^--special ]]; then
special_flag="1"
else
args+=($1)
fi
shift
done
log() {
logging log --source "$THIS_FILE" "$@"
}
_select_addresses() {
local property=$1
local pattern=$2
addresses+=("$(hyprctl clients -j | jq -r ".[] | select($property | contains(\"$pattern\")) | .address")")
}
get_special_addresses() {
# If no arguments, then we add the "special" to the pattern args, which will
# match all windows in any special workspace.
if [[ ${#args} == 0 ]]; then
args+=("special")
fi
for name in ${args[@]}; do
log "Fetching addresses for special: $name"
_select_addresses .workspace.name $name
done
}
close() {
log "Closing window address: $1"
if [[ $dry_run_flag == "0" ]]; then
hyprctl dispatch closewindow "address:$1" >/dev/null 2>&1
fi
}
# Setup logging file and label
source "$SCRIPTS/hypr/logging"
setup-logging "$LOG_LABEL"
export LOG_ENABLE_DRY_RUN="$dry_run_flag"
if [[ $active_workspace_flag == "1" ]]; then
# Set addresses to active workspace windows.
id=$(hyprctl activeworkspace -j | jq -r '.id')
log "Fetching addresses for active workspace: $id"
addresses+=("$(hyprctl clients -j | jq -r ".[] | select(.workspace.id == $id) | .address")")
elif [[ $all_flag == "1" ]]; then
# Set addresses to all window addresses.
addresses+=("$(hyprctl clients -j | jq -r ".[] | .address")")
elif [[ $class_flag == "1" ]]; then
# Set addresses to all windows containing the passed in classes.
for c in ${args[@]}; do
_select_addresses .class $c
done
elif [[ $special_flag == "1" ]]; then
# Set addresses to all windows in the passed in special workspaces.
get_special_addresses
else
# If no modes selected, then assume there were addresses passed in
# as args.
addresses=("$args")
fi
if [[ ${#addresses} == 0 ]]; then
log --warning "No windows found."
exit 0
fi
for address in ${addresses[@]}; do
close $address
done

View File

@@ -76,9 +76,11 @@ sel=$(
--preview-label='[ Window Stats ]' --delimiter='|' --with-nth=2 \ --preview-label='[ Window Stats ]' --delimiter='|' --with-nth=2 \
--preview="$SCRIPTS/hypr/preview-stats window {1}" --preview="$SCRIPTS/hypr/preview-stats window {1}"
) )
status=$?
[[ -z $sel ]] && exit 1 [[ -z $sel ]] && exit 1
# revove everything but the address portion. # revove everything but the address portion.
sel=${sel%%|*} sel=${sel%%|*}
echo "$sel" echo "$sel"
exit $status

View File

@@ -1,241 +0,0 @@
#!/usr/bin/env bash
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE)
usage() {
cat <<EOF
Show a table with details about the currently active windows. You can choose a window and perform
an action. This script will prompt for what you would like to do depending on the options passed.
There are no required options for this script to work.
USAGE:
$ $THIS [OPTIONS]
OPTIONS:
--launch: Launch in a new terminal window, user will be prompted what to do with selected window.
-c | --clip: Copy selected window's address to the system clipboard.
-x | --close: Close the selected window.
-f | --focus: Focus the selected window.
-i | --ignore: Ignore the selected window.
-m | --move: Move the selected window to another workspace and switch to that workspace.
-s | --silent-move: Move the selected window to another workspace and remain on current workspace.
-t | --to-workspace: Used with one of the move options to set which workspace to move to. If not supplied
then we will prompt for a workspace to move to.
--show-window-class: Include window class in the table.
-h | --help: Show this page.
NOTES:
If using the 'launch' option then flags passed after the '--launch' flag will be passed into the
launched terminal, allowing you to launch with a specific mode turned on, any flags passed in prior to
'--launch' will be ignored.
EOF
}
window_class="com.ghostty.window-table"
window_padding_x="10"
clipboard_flag="0"
close_flag="0"
focus_flag="0"
ignore_flag="0"
launch_flag="0"
move_flag="0"
move_silent_flag="0"
move_to_workspace_name=""
show_window_class_flag="0"
launch_args=()
selected_value=""
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
while [[ $# -gt 0 ]]; do
if [[ $launch_flag == "1" ]]; then
launch_args+=("$1")
else
if [[ $1 =~ ^-c ]] || [[ $1 =~ ^--clip ]]; then
clipboard_flag="1"
elif [[ $1 =~ ^-x ]] || [[ $1 =~ ^--close ]]; then
close_flag="1"
elif [[ $1 =~ ^-f ]] || [[ $1 =~ ^--focus ]]; then
focus_flag="1"
elif [[ $1 =~ ^-h ]] || [[ $1 =~ ^--help ]]; then
usage && exit 0
elif [[ $1 =~ ^-i ]] || [[ $1 =~ ^--ignore ]]; then
ignore_flag="1"
elif [[ $1 =~ ^-m ]] || [[ $1 =~ ^--move ]]; then
move_flag="1"
elif [[ $1 =~ ^-s ]] || [[ $1 =~ ^--silent-move ]]; then
move_flag="1"
move_silent_flag="1"
elif [[ $1 =~ ^-t ]] || [[ $1 =~ ^--to-workspace ]]; then
shift
move_to_workspace_name=$1
elif [[ $1 =~ ^--launch ]]; then
launch_flag="1"
elif [[ $1 =~ ^--show-window-class ]]; then
show_window_class_flag="1"
fi
fi
shift
done
action_footer() {
cat <<'EOF'
___ __ _
/ _ |____/ /_(_)__ ___
/ __ / __/ __/ / _ \/ _ \
/_/ |_\__/\__/_/\___/_//_/
EOF
}
log() {
logging log --source "$THIS_FILE" "$@"
}
show_table_return_choice() {
local opts=()
if [[ $show_window_class_flag == "1" ]]; then
opts+=("--show-window-class")
fi
echo $("$SCRIPTS/hypr/window-picker" "${opts[@]}")
}
ask_what_to_do_with_selection() {
local choices=(
"Focus window"
"Close window"
"Move to workspace"
"Move to workspace - silent"
"Copy to clipboard"
"Refresh window list"
"Quit"
)
choice=$(
printf "%s\n" "${choices[@]}" |
fzf --style=full --footer="$(action_footer)" --header="What should we do with the selected window?"
)
log "Choice: $choice"
if [[ $choice == "Quit" ]]; then
exit 0
elif [[ $choice == "Close window" ]]; then
close_flag="1"
elif [[ $choice == "Copy to clipboard" ]]; then
clipboard_flag="1"
elif [[ $choice == "Focus window" ]]; then
focus_flag="1"
elif [[ $choice == "Move to workspace" ]]; then
move_flag="1"
elif [[ $choice == "Move to workspace - silent" ]]; then
move_silent_flag="1"
move_flag="1"
elif [[ $choice == "Refresh window list" ]]; then
eval exec ${BASH_SOURCE[0]}
exit 0
fi
}
# Prevent hyprctl dispatch calls from printing to the console.
hypr_dispatch() {
hyprctl dispatch "$@" >/dev/null 2>&1
return $?
}
move_to_workspace() {
local workspace_id=""
if [[ -z $move_to_workspace_name ]]; then
move_to_workspace_name=$(
$SCRIPTS/hypr/workspace-picker --return-name-if-special \
--header="Select a workspace to move window to:"
)
fi
if [[ -z $move_to_workspace_name ]]; then
log --error "No workspace set to move window to."
exit 1
fi
# Check if moving to a special workspace to pass the appropriate args in to hyprctl.
if [[ $move_to_workspace_name =~ ^special ]]; then
workspace_id=$move_to_workspace_name
else
workspace_id=$(hyprctl workspaces -j | jq -r ".[] | select(.name | contains(\"$move_to_workspace_name\")) | .id")
fi
if [[ -z $workspace_id ]]; then
log --error "No workspace id found for: '$move_to_workspace_name'"
exit 1
fi
action="movetoworkspace"
if [[ $move_silent_flag == "1" ]]; then
action="movetoworkspacesilent"
fi
log "Moving window: '$selected_value' to workspace: '$workspace_id'"
hypr_dispatch $action "$workspace_id,address:$selected_value"
}
handle_selected_value() {
if [[ $ignore_flag == "1" ]]; then
log "Ignore flag set, selection: '$selected_value'"
exit 0
elif [[ $clipboard_flag == "1" ]]; then
log "Copying to clipboard, selection: $selected_value"
wl-copy $selected_value
exit 0
elif [[ $focus_flag == "1" ]]; then
log "Focusing window, selection: $selected_value"
hypr_dispatch focuswindow "address:$selected_value"
exit 0
elif [[ $close_flag == "1" ]]; then
log "Closing window, selection: $selected_value"
hypr_dispatch closewindow "address:$selected_value"
exit 0
elif [[ $move_flag == "1" ]] || [[ $move_silent_flag == "1" ]]; then
move_to_workspace && exit 0
fi
# TODO: Choose from list of what to do with the selected_value.
log "No flag set, selection: '$selected_value'"
}
##################################################
# MAIN
##################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
if [[ $launch_flag == "1" ]]; then
ghostty --class="$window_class" --window-padding-x="$window_padding_x" \
--keybind="ctrl+c=quit" \
-e "${BASH_SOURCE[0]}" "${launch_args[@]}"
else
# Load colors if they haven't been loaded already.
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
[[ -f $SCRIPTS/catppuccin-colors ]] &&
source $SCRIPTS/catppuccin-colors
selected_value=$(show_table_return_choice)
if [[ -n $selected_value ]]; then
handle_selected_value
# If we got here then no flag was passed in initially on how to handle the
# selected window, so ask what they'd like to do. Then handle it.
log "Asking what to do with selction."
ask_what_to_do_with_selection
[[ -n $selected_value ]] && handle_selected_value
# If you make it here, We just give up... Don't start an endless loop.
log "Giving up without a selection."
fi
fi

319
env/.local/scripts/hypr/windowctl vendored Executable file
View File

@@ -0,0 +1,319 @@
#!/usr/bin/env bash
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE)
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
usage() {
cat <<EOF
Show a table with details about the currently active windows. You can choose a window and perform
an action. This script will prompt for what you would like to do depending on the options passed.
There are no required options for this script to work.
USAGE:
$ $THIS [OPTIONS]
OPTIONS:
--launch: Launch in a new terminal window, user will be prompted what to do with selected window.
-c | --clip: Copy selected window's address to the system clipboard.
-x | --close <address>: Close the selected window.
-f | --focus <address>: Focus the selected window, if optional address is supplied then we focus it.
-i | --ignore: Ignore the selected window.
-m | --move <address>: Move the selected window to another workspace and switch to that workspace.
-s | --silent-move <address>: Move the selected window to another workspace and remain on current workspace.
-t | --to-workspace <id>: Used with one of the move options to set which workspace to move to. If not supplied
then we will prompt for a workspace to move to.
-h | --help: Show this page.
NOTES:
If using the 'launch' option then flags passed after the '--launch' flag will be passed into the
launched terminal, allowing you to launch with a specific mode turned on, any flags passed in prior to
'--launch' will be ignored.
EOF
}
if [[ "$1" == "close" ]]; then
shift
THIS="$THIS close" "$SCRIPTS/hypr/utils/windows/close-windows" "$@"
exit $?
fi
window_class="com.ghostty.$THIS"
window_padding_x="10"
clipboard_flag="0"
close_flag="0"
focus_flag="0"
ignore_flag="0"
launch_flag="0"
move_flag="0"
move_silent_flag="0"
move_to_workspace_name=""
refresh_flag="0"
should_quit="0"
launch_args=()
selected_value=""
while [[ $# -gt 0 ]]; do
if [[ $launch_flag == "1" ]]; then
launch_args+=("$1")
else
if [[ $1 =~ ^-c ]] || [[ $1 =~ ^--clip ]]; then
clipboard_flag="1"
elif [[ $1 =~ ^-x ]] || [[ $1 =~ ^--close ]]; then
close_flag="1"
selected_value=$2
shift
elif [[ $1 =~ ^-f ]] || [[ $1 =~ ^--focus ]]; then
focus_flag="1"
selected_value=$2
shift
elif [[ $1 =~ ^-h ]] || [[ $1 =~ ^--help ]]; then
usage && exit 0
elif [[ $1 =~ ^-i ]] || [[ $1 =~ ^--ignore ]]; then
ignore_flag="1"
elif [[ $1 =~ ^-m ]] || [[ $1 =~ ^--move ]]; then
move_flag="1"
selected_value=$2
shift
elif [[ $1 =~ ^-s ]] || [[ $1 =~ ^--silent-move ]]; then
move_flag="1"
move_silent_flag="1"
selected_value=$2
shift
elif [[ $1 =~ ^-t ]] || [[ $1 =~ ^--to-workspace ]]; then
shift
move_to_workspace_name=$1
elif [[ $1 =~ ^--launch ]]; then
launch_flag="1"
fi
fi
shift
done
action_footer() {
cat <<'EOF'
___ __ _
/ _ |____/ /_(_)__ ___
/ __ / __/ __/ / _ \/ _ \
/_/ |_\__/\__/_/\___/_//_/
EOF
}
log() {
logging log --source "$THIS_FILE" "$@"
}
# Reset flags and selection.
reset_flags() {
selected_value=""
clipboard_flag="0"
close_flag="0"
focus_flag="0"
ignore_flag="0"
launch_flag="0"
move_flag="0"
move_silent_flag="0"
move_to_workspace_name=""
refresh_flag="0"
should_quit="0"
}
ask_what_to_do_with_selection() {
local choices=(
"Focus the selected window.:Focus window"
"Close the selected window.:Close window"
"Close the selected window and go back to the window list.:Close window and back"
"Move the selected window to another workspace, focusing the window.\n\nA workspace picker will be presented to choose which workspace to move to.:Move to workspace"
"Move the selected window to another workspace, without focusing the window.\n\nA workspace picker will be presented to choose which workspace to move to.:Move to workspace - silent"
"Copy the window address to the system clipboard:Copy to clipboard"
"Move back to window picker and reload windows.:Back"
"Quit:Quit"
)
choice=$(
printf "%s\n" "${choices[@]}" |
fzf --style=full --footer="$(action_footer)" \
--delimiter=':' --with-nth=2 \
--header="What should we do with the selected window?" \
--preview-label="[ Description ]" \
--preview="echo -e {1}; echo -e '\n\n\e[35mSelected Window:\e[0m'; $SCRIPTS/hypr/preview-stats window $selected_value;"
)
# Set choice to just the action portion.
choice="${choice#*:}"
log "Choice: $choice"
# Set appropriate flags based on the choice.
if [[ $choice == "Quit" ]]; then
exit 0
elif [[ $choice == "Close window" ]]; then
should_quit="1"
close_flag="1"
elif [[ $choice == "Close window and back" ]]; then
close_flag="1"
refresh_flag="1"
should_quit="0"
elif [[ $choice == "Copy to clipboard" ]]; then
should_quit="1"
clipboard_flag="1"
elif [[ $choice == "Focus window" ]]; then
should_quit="1"
focus_flag="1"
elif [[ $choice == "Move to workspace" ]]; then
should_quit="1"
move_flag="1"
elif [[ $choice == "Move to workspace - silent" ]]; then
should_quit="1"
move_silent_flag="1"
move_flag="1"
elif [[ $choice == "Refresh window list" ]]; then
refresh_flag="1"
should_quit="0"
fi
}
# Prevent hyprctl dispatch calls from printing to the console.
hypr_dispatch() {
hyprctl dispatch "$@" >/dev/null 2>&1
return $?
}
move_to_workspace() {
local workspace_id=""
if [[ -z $move_to_workspace_name ]]; then
move_to_workspace_name=$(
$SCRIPTS/hypr/workspace-picker --return-name-if-special \
--header="Select a workspace to move window to:"
)
fi
if [[ -z $move_to_workspace_name ]]; then
log --error "No workspace set to move window to."
exit 1
fi
# Check if moving to a special workspace to pass the appropriate args in to hyprctl.
if [[ $move_to_workspace_name =~ ^special ]]; then
workspace_id=$move_to_workspace_name
else
workspace_id=$(hyprctl workspaces -j | jq -r ".[] | select(.name | contains(\"$move_to_workspace_name\")) | .id")
fi
if [[ -z $workspace_id ]]; then
log --error "No workspace id found for: '$move_to_workspace_name'"
exit 1
fi
action="movetoworkspace"
if [[ $move_silent_flag == "1" ]]; then
action="movetoworkspacesilent"
fi
log "Moving window: '$selected_value' to workspace: '$workspace_id'"
hypr_dispatch $action "$workspace_id,address:$selected_value"
}
focus_window() {
log "Focusing window, selection: $selected_value"
local address="$selected_value"
local name=$(hyprctl clients -j | jq -r ".[] | select(.address == \"$address\") | .workspace.name")
local active_workspace=$(hyprctl activewindow -j | jq -r ".workspace.name")
log "Window workspace: '$name', active workspace: '$active_workspace'"
if [[ $name =~ ^special ]] && [[ ! $active_workspace == $name ]]; then
log "Toggling special workspace prior to focusing window."
name="${name#special:*}"
hypr_dispatch togglespecialworkspace $name
fi
hypr_dispatch focuswindow "address:$address"
}
handle_selected_value() {
if [[ $ignore_flag == "1" ]]; then
log "Ignore flag set, selection: '$selected_value'"
exit 0
elif [[ $clipboard_flag == "1" ]]; then
log "Copying to clipboard, selection: $selected_value"
wl-copy $selected_value
elif [[ $focus_flag == "1" ]]; then
focus_window
elif [[ $close_flag == "1" ]]; then
log "Closing window, selection: $selected_value"
hypr_dispatch closewindow "address:$selected_value"
if [[ $refresh_flag == "1" ]]; then
log "Refreshing windows..."
# Need to sleep here breifly otherwise recently closed windows will still show
# in the window picker.
reset_flags && sleep 0.3
fi
elif [[ $move_flag == "1" ]] || [[ $move_silent_flag == "1" ]]; then
move_to_workspace
# && exit 0
else
log "No flag set, selection: '$selected_value'"
fi
}
##################################################
# MAIN
##################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
log "Starting with selected value: '$selected_value'"
if [[ $launch_flag == "1" ]]; then
ghostty --class="$window_class" --window-padding-x="$window_padding_x" \
--keybind="ctrl+c=quit" \
-e "${BASH_SOURCE[0]}" "${launch_args[@]}"
else
# Load colors if they haven't been loaded already.
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
[[ -f $SCRIPTS/catppuccin-colors ]] &&
source $SCRIPTS/catppuccin-colors
if [[ -n $selected_value ]]; then
# Handle value if it was passed in.
# TODO: This should probably ensure that flags were set.
handle_selected_value && exit 0
else
trap 'log "Stoping..."; should_quit="1"' SIGINT
while [[ $should_quit == "0" ]]; do
# not sure if this should be here or somewhere else, as it will
# cause any passed in flags to be ignored, but they're generally empty
# when using this interactive mode anyway.
reset_flags
selected_value=$("$SCRIPTS/hypr/window-picker")
status=$?
if [[ $status -ne 0 ]]; then
should_quit="1"
else
if [[ -n $selected_value ]]; then
handle_selected_value
# If we got here then no flag was passed in initially on how to handle the
# selected window, so ask what they'd like to do. Then handle it.
log "Asking what to do with selction."
ask_what_to_do_with_selection
[[ -n $selected_value ]] && handle_selected_value
# If you make it here, We just give up... Don't start an endless loop.
# log "Giving up without a selection."
fi
fi
done
fi
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

5
env/webapps/mychart.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"name": "My Chart - UC Health",
"url": "https://my.uchealth.com/myuchealth/Home",
"icon": "mychart.png"
}

5
gen
View File

@@ -76,7 +76,8 @@ generate_script() {
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts} SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
THIS_FILE=${BASH_SOURCE[0]} THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE) LOG_LABEL=$(basename "$THIS_FILE")
THIS=${THIS:-$LOG_LABEL}
# Logging utility function, use in place of echo. # Logging utility function, use in place of echo.
log() { log() {
@@ -89,7 +90,7 @@ log() {
# Setup logging file and label. # Setup logging file and label.
source "$SCRIPTS/hypr/logging" source "$SCRIPTS/hypr/logging"
setup-logging "$THIS" setup-logging "$LOG_LABEL"
log "Starting $THIS..." log "Starting $THIS..."