From 85a20032a7ddd1c8d5790107be090572f917e161 Mon Sep 17 00:00:00 2001 From: Juni Kim Date: Sat, 7 Dec 2024 23:34:56 -0500 Subject: [PATCH] kill.sh added --- .config/hypr/hyprland.conf | 2 +- .local/bin/kill.sh | 7 ++++ .local/bin/tmuxs | 70 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100755 .local/bin/kill.sh create mode 100755 .local/bin/tmuxs diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index eebdb05..2eba546 100644 --- a/.config/hypr/hyprland.conf +++ b/.config/hypr/hyprland.conf @@ -211,7 +211,7 @@ $mainMod = SUPER # Sets "Windows" key as main modifier # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more bind = $mainMod SHIFT, A, exec, $terminal bind = $mainMod SHIFT, Q, killactive, -bind = $mainMod SHIFT, E, exit, +bind = $mainMod SHIFT, E, exec, kill.sh #bind = $mainMod, E, exec, $fileManager bind = $mainMod SHIFT, W, exec, firefox bind = $mainMod, V, togglefloating, diff --git a/.local/bin/kill.sh b/.local/bin/kill.sh new file mode 100755 index 0000000..60407ba --- /dev/null +++ b/.local/bin/kill.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +QUIT=$(printf "No\nYes" | rofi -dmenu -i -p "Are you sure u want to kill Hyprland?") + +if test "$QUIT" == "Yes" ; then + pkill Hyprland +fi diff --git a/.local/bin/tmuxs b/.local/bin/tmuxs new file mode 100755 index 0000000..a1ec4f2 --- /dev/null +++ b/.local/bin/tmuxs @@ -0,0 +1,70 @@ +#!/usr/bin/env sh + +WORKSPACES=${WORKSPACES:-$HOME/Documents:$HOME/docs/prg} + +IFS=':' findargs=$WORKSPACES + +while test $# -gt 0; do + case "$1" in + -d|--depth) + shift + if test -z "$1"; then + echo "No appropriate option given after depth" + exit 1 + else + depth="$1" + fi + shift; + ;; + -*) + echo "Invalid option $1" + exit 1 + ;; + *) + sessiondir="$1" + shift; + ;; + esac +done + +if test -z "$sessiondir"; then + if ! test -z "$depth" && test "$depth" -eq 0; then + sessiondir="$(find $findargs\ + \! -name '*.git*'\ + \! -name '*.vscode*'\ + \! -name '*.idea*'\ + \! -name '*node_modules*'\ + \! -name '*__pycache__*'\ + \! -name '*venv*'\ + -type d 2>/dev/null | fzf)" + else + sessiondir="$(find $findargs -maxdepth ${depth:-2}\ + \! -name '*.git*'\ + \! -name '*.vscode*'\ + \! -name '*.idea*'\ + \! -name '*node_modules*'\ + \! -name '*__pycache__*'\ + \! -name '*venv*'\ + -type d 2>/dev/null | fzf)" + fi +fi + +if test -z "$sessiondir" || ! test -d "$sessiondir"; then + echo "$sessiondir is not a directory. Aborting..." + exit 0 +fi + +name="$(realpath "$sessiondir" | tr '.' '_')" + +if test -z "$TMUX" && test -z "$(pgrep tmux)"; then + tmux new-session -c "$sessiondir" -s "$name" +else + if ! tmux has-session -t="$name" 2> /dev/null; then + tmux new-session -d -c "$sessiondir" -s "$name" + fi + if test -z "$TMUX"; then + tmux attach -t "$name" + else + tmux switch-client -t "$name" + fi +fi