diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/.scripts/: basename | 1 | ||||
| -rw-r--r-- | scripts/.scripts/basename | 1 | ||||
| -rwxr-xr-x | scripts/.scripts/config_files.sh | 36 | ||||
| -rwxr-xr-x | scripts/.scripts/specialworkspace_mover.sh | 52 | ||||
| -rwxr-xr-x | scripts/.scripts/tmux-sessionizer.sh | 39 |
5 files changed, 111 insertions, 18 deletions
diff --git a/scripts/.scripts/: basename b/scripts/.scripts/: basename new file mode 100644 index 0000000..d46ba07 --- /dev/null +++ b/scripts/.scripts/: basename @@ -0,0 +1 @@ + "alacritty:$HOME/dotfiles/alacritty/.config/alacritty/alacritty.toml" diff --git a/scripts/.scripts/basename b/scripts/.scripts/basename new file mode 100644 index 0000000..d46ba07 --- /dev/null +++ b/scripts/.scripts/basename @@ -0,0 +1 @@ + "alacritty:$HOME/dotfiles/alacritty/.config/alacritty/alacritty.toml" diff --git a/scripts/.scripts/config_files.sh b/scripts/.scripts/config_files.sh index c4d5451..8642cf4 100755 --- a/scripts/.scripts/config_files.sh +++ b/scripts/.scripts/config_files.sh @@ -1,4 +1,36 @@ #!/usr/bin/sh -file=$(find "$HOME/dotfiles/" -type f | dmenu -l 20 -p "open config file") -kitty -e nvim $file +configs=("aliases:$HOME/dotfiles/aliases/.aliases/aliases" + "alacritty:$HOME/dotfiles/alacritty/.config/alacritty/alacritty.toml" + "awesome:$HOME/dotfiles/awesome/.config/awesome/rc.lua" + "kitty:$HOME/dotfiles/kitty/.config/kitty/kitty.conf" + "hyprland:$HOME/dotfiles/hypr/.config/hypr/hyprland.conf" + "vim:$HOME/dotfiles/vim/.vimrc" + "neovim:$HOME/dotfiles/nvim/.config/nvim/init.lua" + "starship:$HOME/dotfiles/starship/.config/starship.toml" + "tmux:$HOME/dotfiles/tmux/.tmux.conf" + "zathura:$HOME/dotfiles/zathura/.config/zathura/zathurarc" + "zsh:$HOME/dotfiles/zsh/.zshrc") + +configs=$(printf '%s\n' "${configs[@]}") + +# Detect whether we're in a Wayland or X11 session +if [ "$XDG_SESSION_TYPE" = "wayland" ]; then + # Wayland session - use wofi + launcher="wofi --dmenu -i -l 10" +elif [ "$XDG_SESSION_TYPE" = "x11" ]; then + # X11 session - use dmenu + launcher="dmenu -i -l 10 -p 'open config file'" +else + echo "Error: Could not detect display server (Wayland or X11)." + exit 1 +fi + +program_names=$(echo "$configs" | cut -d':' -f1) + +choice=$(echo "$program_names" | $launcher) + +file=$(echo "$configs" | grep -w "$choice" | cut -d':' -f2) + +cwd=$(dirname $file) +kitty -e nvim -c "cd $cwd" $file diff --git a/scripts/.scripts/specialworkspace_mover.sh b/scripts/.scripts/specialworkspace_mover.sh new file mode 100755 index 0000000..7e94d03 --- /dev/null +++ b/scripts/.scripts/specialworkspace_mover.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Fetch all clients' information using hyprctl +clients_output=$(hyprctl clients) + +# Extract window classes for workspace -99 +special_windows=$(echo "$clients_output" | awk ' + BEGIN { RS="Window "; FS="\n" } + /workspace: -99/ { + for (i=1; i<=NF; i++) { + if ($i ~ /class:/) { + class = $i + sub("class: ", "", class) + print class + } + } + } +') + +# Check if there are any windows in the special workspace +if [[ -z "$special_windows" ]]; then + echo "No windows found in the special workspace." + exit 0 +fi + +# Display the window classes in wofi and get the selected window class +selected_class=$(echo "$special_windows" | wofi --dmenu -p "Select a window to move:" | awk '{$1=$1};1') + +# Exit if no selection was made +if [[ -z "$selected_class" ]]; then + echo "No selection made." + exit 0 +fi + +window_title=$(hyprctl clients | grep -i -E "Window .* $selected_class" | sed "s/Window.*-> \(.*\):/\1/I") + +echo "Special windows: $special_windows" +echo "Selected class: $selected_class" +echo "Window title: $window_title" + +current_workspace=$(hyprctl activeworkspace | head -n1 | cut -d' ' -f3) + +echo "Curspace: $current_workspace" +# hyprctl dispatch movetoworkspacesilent 1,title:"Thinking in Systems - volty - Obsidian v1.7.7" + +# Move the selected window to the current workspace +if [[ -n "$window_title" ]]; then + hyprctl dispatch movetoworkspacesilent "$current_workspace",title:"$window_title" + echo "Moved $selected_class to the current workspace." +else + echo "Failed to find window ID for $selected_class." +fi diff --git a/scripts/.scripts/tmux-sessionizer.sh b/scripts/.scripts/tmux-sessionizer.sh index c536df7..419484a 100755 --- a/scripts/.scripts/tmux-sessionizer.sh +++ b/scripts/.scripts/tmux-sessionizer.sh @@ -1,29 +1,36 @@ #!/bin/sh - if [[ $# -eq 1 ]]; then - selected=$1 + selected=$1 else - selected=$(find ~/programming -mindepth 1 -maxdepth 2 -type d | fzf) + selected=$(fd '^.git$' -a --hidden --no-ignore --type d ./programming --exec dirname | grep -v "thirdparties" | fzf) fi if [[ -z $selected ]]; then - exit 1 + exit 1 fi selected_name=$(basename "$selected" | tr . _) tmux_running=$(pgrep tmux) -if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then - tmux new-session -s $selected_name - tmux send-keys -t $selected_name "cd $selected" Enter - tmux send-keys -t $selected_name "clear" Enter - exit 0 -fi +create_session() { + tmux new-session -d -s $selected_name -n nvim + tmux send-keys -t "$selected_name:1" "cd $selected && clear && nvim ." Enter + # Create second window (shell) + tmux new-window -t $selected_name -n shell + tmux send-keys -t "$selected_name:2" "cd $selected && clear" Enter + # Create third window (git) + tmux new-window -t $selected_name -n git + tmux send-keys -t "$selected_name:3" "cd $selected && clear && lazygit" Enter +} -if ! tmux has-session -t=$selected_name 2> /dev/null; then - tmux new-session -ds $selected_name - tmux send-keys -t $selected_name "cd $selected" Enter - tmux send-keys -t $selected_name "clear" Enter +# If not in tmux, create and attach +if [[ -z $TMUX ]]; then + create_session + tmux attach-session -t $selected_name +else + # If in tmux, create if needed and switch + if ! tmux has-session -t=$selected_name 2>/dev/null; then + create_session + fi + tmux switch-client -t $selected_name fi - -tmux switch-client -t $selected_name |
