Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions bin/omakub-launch-walker
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,44 @@
# See: https://github.com/abenz1267/walker/pull/708

DIMS_FILE="${XDG_STATE_HOME:-$HOME/.local/state}/omakub/walker-service-dims"
CONFIG_FILE="${HOME}/.config/walker/config.toml"

# Ensure elephant (Walker data provider) is running
pgrep -x elephant > /dev/null || elephant &

# gtk4-layer-shell renders Walker incorrectly on X11; use a normal window there instead.
want_as_window=false
if [[ ${XDG_SESSION_TYPE:-} == "x11" ]]; then
want_as_window=true
fi

current_as_window=$(awk '/^as_window = / { print $3; exit }' "$CONFIG_FILE" 2>/dev/null)
if [[ $current_as_window != "$want_as_window" ]]; then
if [[ -n $current_as_window ]]; then
sed -i "s/^as_window = .*/as_window = $want_as_window/" "$CONFIG_FILE"
else
sed -i "1ias_window = $want_as_window" "$CONFIG_FILE"
fi
pkill -x walker 2>/dev/null
while pgrep -x walker > /dev/null; do sleep 0.05; done
fi

# Resolve effective dimensions: defaults, overridden by caller args
width=644; minheight=300; maxheight=300
# --height is the overall window; min/maxheight only size the scrolled list inside it.
width=644; height=0; minheight=300; maxheight=300
args=("$@")
for i in "${!args[@]}"; do
case "${args[i]}" in
--width) width="${args[i+1]}" ;;
--minheight) minheight="${args[i+1]}" ;;
--maxheight) maxheight="${args[i+1]}" ;;
--width|-w) width="${args[i+1]}" ;;
--height) height="${args[i+1]}" ;;
--minheight) minheight="${args[i+1]}" ;;
--maxheight) maxheight="${args[i+1]}" ;;
esac
done

# Kill ALL walker processes (client + service) when dimensions change.
# Not killing on dim change causes the service to cap new windows to its initially-cached size.
dims_key="w${width}x${minheight}-${maxheight}"
dims_key="w${width}h${height}x${minheight}-${maxheight}"
mkdir -p "$(dirname "$DIMS_FILE")"
if [[ $(cat "$DIMS_FILE" 2>/dev/null) != $dims_key ]] && pgrep -x walker > /dev/null; then
pkill -x walker
Expand All @@ -35,6 +55,7 @@ echo "$dims_key" > "$DIMS_FILE"
# Inject defaults only for dimensions not explicitly passed by the caller.
defaults=()
[[ $* != *--width* ]] && defaults+=(--width $width)
[[ $* != *--height* && $height -gt 0 ]] && defaults+=(--height $height)
[[ $* != *--minheight* ]] && defaults+=(--minheight $minheight)
[[ $* != *--maxheight* && $* != *--minheight* ]] && defaults+=(--maxheight $maxheight)

Expand Down
2 changes: 1 addition & 1 deletion bin/omakub-menu
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ menu() {
fi
fi

echo -e "$options" | omakub-launch-walker --dmenu --width 295 --minheight 1 --maxheight 630 -p "$prompt…" "${args[@]}" 2>/dev/null
echo -e "$options" | omakub-launch-walker --dmenu --width 295 --minheight 280 --maxheight 630 -p "$prompt…" "${args[@]}" 2>/dev/null
}

terminal() {
Expand Down
4 changes: 2 additions & 2 deletions default/walker/themes/omakub-default/layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
<property name="can_focus">false</property>
<property name="overlay-scrolling">true</property>
<property name="max-content-width">600</property>
<property name="max-content-height">300</property>
<property name="min-content-height">0</property>
<property name="max-content-height">560</property>
<property name="min-content-height">280</property>
<property name="propagate-natural-height">true</property>
<property name="propagate-natural-width">true</property>
<property name="hscrollbar-policy">automatic</property>
Expand Down