#!/bin/zsh
setopt no_unset
cmds=(
	lock
	show-inbox
	root-terminal
	terminal-wpa_cli
	\!open-im
	\!ff
	\!ff_{recombee,te2000}_sndio
	'!scrot -d 2 -u'
	exit
	adjust-brightness/{1,2,3,4,5,6,7,8,9,10}0%
)
# cmds+=( "${(f@)"$(
# 	 sed 's|.*|abduco!&!shell!zsh -li|' ~/.config/containers/list
# )"}" )

cmds+=( "${(f@)"$(
awk '{
	printf("abduco/%s/shell/zsh -li\n", $0);
	printf("abduco/%s/tmux/tmux -2u new-session -s abduco -A\n", $0);
}' ~/.config/containers/list
)"}" )

cmds+=(
	ssh{,2}/{dorje,hexusb,saturnin,daruma,ccx.blesmrt.net}
)

# --- new implementation

cmds=( "${(f@)"$(
	s6-ipcclient /run/powerbox-menu-list.s s6-ioconnect
)"}" )

cmds+=(
	\!open-im
	\!ff
	\!ff_{recombee,te2000}_sndio
	'!scrot -d 2 -u'
)

for sock in /run/vnc.59*(N); do
	cmds+=( "!gvncviewer 127.0.0.1:${sock##*/vnc.59}" )
done

choice=$( dmenu -fn 'Misc Fixed:semicondensed:pixelsize=13:lang=cs' <<<${(F)cmds} )
case $choice in
	('!'*) eval ${choice#!};;
	('') exit 0;;
	(*) exec powerbox-plumb "$choice";;
esac