aboutsummaryrefslogtreecommitdiff
path: root/scripts/.scripts/config_files.sh
blob: 57040554da46885350dcf305d77b9fc492c5d39c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/sh

configs=(
  "aliases:$HOME/dotfiles/aliases/.aliases/aliases"
  "alacritty:$HOME/dotfiles/alacritty/.config/alacritty/alacritty.toml"
  "wezterm:$HOME/dotfiles/wezterm/.config/wezterm/wezterm.lua"
  "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"
  "yazi:$HOME/dotfiles/yazi/.config/yazi/keymap.toml"
  "ghostty:$HOME/dotfiles/ghostty/.config/ghostty/config"
)

configs=$(printf '%s\n' "${configs[@]}")

# Detect whether we're in a Wayland or X11 session
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
  # Wayland session - use rofi with theme override
  launcher=(rofi -dmenu -l 10 -theme-str "window { width: 45%; }")
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[@]}")

# Exit silently if Escape was pressed or menu was closed
[ -z "$choice" ] && exit 0

file=$(echo "$configs" | grep -w "$choice" | cut -d':' -f2)

cwd=$(dirname "$file")
kitty -e nvim -c "cd $cwd" "$file"