11#! /bin/bash
2- # Unified Cheatsheet Viewer with rofi search
2+ # Unified Cheatsheet Viewer with launcher search
33# i3: Execute keybinding on Enter
44# Others: Copy command to clipboard on Enter
55
66set -u
77
8+ # Source global defaults
9+ if [ -f " ${HOME} /.config/environment.d/defaults.conf" ]; then
10+ . " ${HOME} /.config/environment.d/defaults.conf"
11+ fi
12+
13+ # Fallback if not set
14+ LAUNCHER=" ${LAUNCHER:- rofi} "
15+
816SCRIPT_DIR=" ${HOME} /.config/i3/scripts"
917CHEATSHEETS_DIR=" ${SCRIPT_DIR} /cheatsheets"
1018I3_CONFIG=" ${HOME} /.config/i3/config"
@@ -21,8 +29,8 @@ check_dependencies() {
2129 local missing=()
2230
2331 # Required
24- if ! command -v rofi & > /dev/null; then
25- missing+=(" rofi " )
32+ if ! command -v " $LAUNCHER " & > /dev/null; then
33+ missing+=(" $LAUNCHER " )
2634 fi
2735
2836 # At least one clipboard tool
@@ -31,7 +39,7 @@ check_dependencies() {
3139 fi
3240
3341 if [ ${# missing[@]} -gt 0 ]; then
34- # Try to show error via rofi if available , otherwise echo
42+ # Try to show error via notification , otherwise echo
3543 local msg=" Missing required commands: ${missing[*]} "
3644 if command -v notify-send & > /dev/null; then
3745 notify-send " Cheatsheet Error" " $msg " -u critical
@@ -138,7 +146,7 @@ show_categories() {
138146 fi
139147 fi
140148
141- printf ' %s' " $categories " | sort -u | rofi -dmenu -i -p " Category" \
149+ printf ' %s' " $categories " | sort -u | " $LAUNCHER " -dmenu -i -p " Category" \
142150 -no-show-icons \
143151 -theme-str ' window {location: center; anchor: center; width: 300px;}' \
144152 -theme-str ' listview {lines: 12; scrollbar: true;}'
@@ -170,7 +178,7 @@ show_i3() {
170178 sed ' s/^[[:space:]]*## //' | \
171179 sed ' s/ ##$//' | \
172180 awk -F ' // ' ' {printf "%-12s │ %-25s │ %s\n", $1, $2, $3}' | \
173- rofi -dmenu -i -p " $prompt " \
181+ " $LAUNCHER " -dmenu -i -p " $prompt " \
174182 -no-show-icons \
175183 -theme-str ' window {location: center; anchor: center; width: 800px; height: 70%;}' \
176184 -theme-str ' listview {lines: 15; scrollbar: true; fixed-height: false;}' \
@@ -194,7 +202,7 @@ show_i3() {
194202 if [ -n " $xdotool_key " ]; then
195203 # Validate key sequence before execution (security)
196204 if validate_xdotool_key " $xdotool_key " ; then
197- # Small delay to let rofi close
205+ # Small delay to let launcher close
198206 sleep 0.1
199207 xdotool key " $xdotool_key " || true
200208 else
@@ -236,7 +244,7 @@ show_cheatsheet() {
236244 fi
237245
238246 local selected
239- selected=$( rofi -dmenu -i -p " $name (Enter to copy)" \
247+ selected=$( " $LAUNCHER " -dmenu -i -p " $name (Enter to copy)" \
240248 -no-show-icons \
241249 -theme-str ' window {location: center; anchor: center; width: 850px; height: 70%;}' \
242250 -theme-str ' listview {lines: 15; scrollbar: true; fixed-height: false;}' \
0 commit comments