summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bluemenu59
-rwxr-xr-xbin/connmenu76
-rwxr-xr-xbin/menu50
-rwxr-xr-xbin/modemenu34
-rwxr-xr-xbin/notifmenu2
-rwxr-xr-xbin/rcmenu60
-rwxr-xr-xbin/secretmenu47
-rwxr-xr-xbin/soundswitch305
8 files changed, 361 insertions, 272 deletions
diff --git a/bin/bluemenu b/bin/bluemenu
new file mode 100755
index 0000000..22ac87b
--- /dev/null
+++ b/bin/bluemenu
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+set -e
+[ -n "$DEBUG" ] && set -x
+export UNSAFE=1
+
+# notifysend() {
+# 	[ -z "$notifyicon" ] && notifyicon=bluetooth
+# 	local msg=$1
+# 	shift 1
+# 	echo "$msg"
+# 	notification_id=$(notify-send "bluetooth" "$msg" -i "$(iconez -sn "$notifyicon")" --print-id "$@")
+# }
+
+if [ -n "$BTON" ]; then
+	bluetoothctl power on
+	exit $?
+fi
+
+if [ -n "$BTOFF" ]; then
+	bluetoothctl power off
+	exit $?
+fi
+
+if [ -n "$BTCONNECT" ]; then
+	if [ -n "$REEXEC" ]; then
+		addr=$1
+
+		if bluetoothctl devices Connected | grep -q "$addr"; then
+			bluetoothctl disconnect "$addr"
+		else
+			bluetoothctl connect "$addr"
+			sleep 2
+			# hack to make wireplumber detect bt audio device
+			pkill -USR2 wireplumber
+		fi
+
+		exit $?
+	fi
+
+	bluetoothctl power on
+	bluetoothctl devices |
+		while read -r btdev; do
+			name=$(cut -d' ' -f3 <<<"$btdev")
+			addr=$(cut -d' ' -f2 <<<"$btdev")
+
+			jq -cnr \
+				--arg label "$name $addr" \
+				--arg addr "$addr" \
+				'{l:$label,x:(["env BTCONNECT=1 REEXEC=1 bluemenu", $addr]|join(" "))}'
+		done |
+		jq -cs '{p:"bluemenu", o:.}' |
+		mkmenu
+
+	exit $?
+fi
+
+jq -cn '{p:"bluetooth",o:[{l:"power on",x:"env BTON=1 bluemenu"},{l:"power off",x:"env BTOFF=1 bluemenu"},{l:"connect...",x:"env BTCONNECT=1 bluemenu"}]}' |
+	mkmenu
diff --git a/bin/connmenu b/bin/connmenu
index d3285dc..9faa5de 100755
--- a/bin/connmenu
+++ b/bin/connmenu
@@ -25,10 +25,13 @@ notifysend() {
 	[ -z "$notifyicon" ] && notifyicon=wifi
 	local msg=$1
 	shift 1
+	echo "$msg"
 	notification_id=$(notify-send "connman" "$msg" -i "$(iconez -sn "$notifyicon")" --print-id "$@")
 }
 
 get_services() {
+	# if [[ -f $SCAN_RESULT ]] && [[ $(($(date +%s) - $(stat -c %Y $SCAN_RESULT))) -gt 9000 ]]; then
+
 	if [[ -f $SCAN_RESULT ]]; then
 		notifysend 'another connman_dmenu is running'
 		exit 1
@@ -38,7 +41,7 @@ get_services() {
 	local notifyicon=wifi-sync
 	notifysend "scanning for wifi services..." --expire-time=0
 
-	trap "rm -f $SCAN_RESULT" EXIT
+	trap 'rm -f $SCAN_RESULT' EXIT
 	connmanctl enable wifi &>/dev/null
 	connmanctl scan wifi &>/dev/null
 	clear-notification "$notification_id"
@@ -163,43 +166,56 @@ security="$(get_service_security "$service_id")"
 
 # create service file for encryption
 if [[ ! "$name" =~ ^\* ]] && [[ "$security" =~ ^(ieee8021x|psk|wep)$ ]]; then
-	notifysend 'setting up connection not implemented' -c error
-	# config_file="$STORAGE_PATH/$name-$security.config"
+	swx -t connmanctl
+	wtype -s 200 "agent on"
+	wtype -s 200 -k enter
+	wtype -s 200 "connect $service_id"
+	wtype -s 200 -k enter
+
+	# config_file="$STORAGE_PATH/$service_id/settings"
 	# if [[ -f "$config_file" && no != "$(echo -e 'yes\nno' | dmenu -p '󱛆 use previous profile?')" ]]; then
 	# 	echo "use old profile: $config_file"
 	# else
+	# 	password=
 	# 	dmenu_ask 'please provide password' password --password
+	# 	[ -n "$password" ] || exit 1
+	#
 	# 	case "$security" in
 	# 	ieee8021x)
-	# 		dmenu_ask 'please provide identity' identity
-	# 		case "$(echo -e 'PEAP/MSCHAPV2\nTTLS/PAP' | dmenu -p '󱛆 please specify EAP type')" in
-	# 		PEAP/MSCHAPV2)
-	# 			eap=peap
-	# 			phase2=MSCHAPV2
-	# 			;;
-	# 		TTLS/PAP)
-	# 			eap=ttls
-	# 			phase2=PAP
-	# 			;;
-	# 		*)
-	# 			(
-	# 				notifyicon=wifi-alert
-	# 				notifysend 'invalid EAP' -c error
-	# 			)
-	# 			exit 1
-	# 			;;
-	# 		esac
-	# 		cat >"$config_file" <<-EOF
-	# 			[service_$service_id]
-	# 			Type = wifi
-	# 			Name = $name
-	# 			EAP = $eap
-	# 			Phase2 = $phase2
-	# 			Identity = $identity
-	# 			Passphrase = $password
-	# 		EOF
+	# 		notifysend "unable to setup $security networks" -c error
+	# 		exit 1
+	#
+	# 		# dmenu_ask 'please provide identity' identity
+	# 		# case "$(echo -e 'PEAP/MSCHAPV2\nTTLS/PAP' | dmenu -p '󱛆 please specify EAP type')" in
+	# 		# PEAP/MSCHAPV2)
+	# 		# 	eap=peap
+	# 		# 	phase2=MSCHAPV2
+	# 		# 	;;
+	# 		# TTLS/PAP)
+	# 		# 	eap=ttls
+	# 		# 	phase2=PAP
+	# 		# 	;;
+	# 		# *)
+	# 		# 	(
+	# 		# 		notifyicon=wifi-alert
+	# 		# 		notifysend 'invalid EAP' -c error
+	# 		# 	)
+	# 		# 	exit 1
+	# 		# 	;;
+	# 		# esac
+	# 		# mkdir -p "$(dirname "$config_file")"
+	# 		# cat >"$config_file" <<-EOF
+	# 		# 	[service_$service_id]
+	# 		# 	Type = wifi
+	# 		# 	Name = $name
+	# 		# 	EAP = $eap
+	# 		# 	Phase2 = $phase2
+	# 		# 	Identity = $identity
+	# 		# 	Passphrase = $password
+	# 		# EOF
 	# 		;;
 	# 	psk | wep)
+	# 		mkdir -p "$(dirname "$config_file")"
 	# 		cat >"$config_file" <<-EOF
 	# 			[service_$service_id]
 	# 			Type = wifi
diff --git a/bin/menu b/bin/menu
index 23e7801..b3e4759 100755
--- a/bin/menu
+++ b/bin/menu
@@ -3,65 +3,45 @@ set -e
 [ -n "$DEBUG" ] && set -x
 
 # make sure there we are the only running menu
-pgrep -x bemenu >/dev/null && killall -INT bemenu
+pgrep bemenu >/dev/null && pkill -f bemenu
 
 # always source the config to make sure
 . "$HOME"/.config/bemenu.conf
 
 arg0=bemenu
-prompt=${MENU_PROMPT:-󰈶󰩤}
-args=
+MENU_PROMPT=${MENU_PROMPT:-󰈶󰩤}
 
 idx=0
 while test $# -gt $idx; do
 	case "$1" in
 	-run)
 		arg0=bemenu-run
-		prompt="󰏌"
+		MENU_PROMPT="󰏌"
 		shift
 		;;
 	-drun)
-		# arg0=bemenu-drun
-		# prompt="󱂬"
+		arg0="j4-dmenu-desktop --dmenu=bemenu"
+		MENU_PROMPT="󱂬"
 		shift
-		desktopfiles() {
-			fd -e desktop . \
-				/usr/share/applications/ \
-				/usr/local/share/applications/ \
-				/var/lib/flatpak/app/*/current/active/export/share/applications/ \
-				"$XDG_DATA_HOME"/applications/ 2>/dev/null || true
-		}
-		list_apps() {
-			desktopfiles |
-				xargs -I{} awk -F= '/^Name=/{ print $2;exit; }' {} |
-				sort -u
-		}
-		get_desktopfile() {
-			desktopfiles |
-				xargs -I{} awk -v name="$1" -F= '/^Name=/{ if($2==name) print FILENAME }' {} |
-				sort -u |
-				head -n1
-		}
-		app=$(list_apps | MENU_PROMPT="󱂬" "$0")
-		[ -z "$app" ] && exit 0
-		desktopfile=$(get_desktopfile "$app")
-		[ -z "$desktopfile" ] && exit 0
-		nohup xdg-exec "$desktopfile" "$@" >/dev/null 2>&1 &
-		exit 0
 		;;
 	-p)
 		shift
-		prompt="$1"
+		MENU_PROMPT="$1"
 		shift
 		;;
 	-x)
 		shift
-		MENU_PASSWORD=1
+		BEMENU_OPTS="${BEMENU_OPTS} --password"
 		;;
 	esac
 	idx=$((idx + 1))
 done
 
-[ -n "${MENU_PASSWORD}" ] && args="${args} --password"
-[ -n "${MENU_POPUP}" ] && args="${args} --center --width-factor 0.5 --border 2 --list 8" # --fixed-height
-exec "${arg0}" --prompt "${prompt}" ${args} "$@"
+[ -n "${MENU_POPUP}" ] &&
+	BEMENU_OPTS="${BEMENU_OPTS} --center --width-factor 0.5 --border 2 --list 8" # --fixed-height
+
+BEMENU_OPTS="${BEMENU_OPTS} --prompt ${MENU_PROMPT}"
+
+BEMENU_OPTS="${BEMENU_OPTS} $*"
+
+exec ${arg0}
diff --git a/bin/modemenu b/bin/modemenu
new file mode 100755
index 0000000..64ef18e
--- /dev/null
+++ b/bin/modemenu
@@ -0,0 +1,34 @@
+#!/bin/bash
+set -e
+[ -n "$DEBUG" ] && set -x
+
+get_output() {
+	swaymsg -t get_outputs |
+		jq -cr '.[] | select(.type=="output") | [.name, .make + " " + .model] | @tsv' |
+		menu --accept-single |
+		cut -d $'\t' -f 1
+}
+
+list_modes() {
+	local output=$1
+	swaymsg -t get_outputs |
+		jq -cr --arg name "$output" '.[] | select(.type=="output" and .name==$name) | .modes[] | [([.width, "x", .height, "@", .refresh, "Hz"]|join("")), .picture_aspect_ratio // ""] | @tsv'
+}
+
+output=$(get_output)
+
+mode=$( (
+	list_modes "$output"
+	echo -e "\tset scale..."
+) | column -t -s $'\t' |
+	menu)
+
+case "$mode" in
+*"set scale"*)
+	scale=$(echo -e "1.0\n1.5\n2.0" | MENU_PROMPT="set scale" menu)
+	exec swaymsg output "$output" scale "$scale"
+	;;
+*)
+	exec swaymsg output "$output" mode "$mode"
+	;;
+esac
diff --git a/bin/notifmenu b/bin/notifmenu
index 48f8ca6..6b993a6 100755
--- a/bin/notifmenu
+++ b/bin/notifmenu
@@ -33,7 +33,7 @@ done
 export MENU_PROMPT="󰡟 notif"
 
 _menu() {
-	menu -l10 --ifne --autoselect "$@"
+	menu -l10 --ifne --accept-single "$@"
 }
 
 list_notifications() {
diff --git a/bin/rcmenu b/bin/rcmenu
index 223d597..c2a359d 100755
--- a/bin/rcmenu
+++ b/bin/rcmenu
@@ -28,28 +28,42 @@ __list() {
 	) | column -t
 }
 
+__start() {
+	local sv=$1
+	export msg=$(doas -n s6-rc -v2 -u change "$sv")
+	export action=start
+}
+__stop() {
+	local sv=$1
+	export msg=$(doas -n s6-rc -v2 -d change "$sv")
+	export action=stopp
+}
+__restart() {
+	local sv="$1"
+	local msg
+	local action
+
+	# bemenu-ism
+	# if [ $menu_exitcode -eq 18 ]; then
+	if jq -ncr '{p:"rcmenu",o:[{l:"restart",x:"false"},{l:"stop",x:"true"}]}' | mkmenu; then
+		__stop "$sv"
+	else
+		__stop "$sv" && sleep 0.5 && __start "$sv"
+		action=restart
+	fi
+
+	export msg
+	export action
+}
+
 __handle() {
 	while read -r line; do
 		sv=$(printf "%s" "${line}" | awk '{print $1}')
 		state=$(printf "%s" "${line}" | awk '{print $2}')
 
 		case "$state" in
-		up | \[bundle\])
-			msg=$(doas -n s6-rc -v2 -d change "$sv")
-			if [ $menu_exitcode -eq 18 ]; then
-				action=stopp
-			else
-				action=restart
-				sleep 0.5
-				msg=$(doas -n s6-rc -v2 -u change "$sv")
-			fi
-			;;
-
-		down)
-			action=start
-			msg=$(doas -n s6-rc -v2 -u change "$sv")
-			;;
-
+		up | \[bundle\]) __restart "$sv" ;;
+		down) __start "$sv" ;;
 		*)
 			action=noop
 			msg=$(printf "unknown service state: %s\n" "$state")
@@ -66,6 +80,14 @@ __handle() {
 	done
 }
 
-svs=$(__list | menu --list=10)
-menu_exitcode=$?
-__handle <<<"$svs"
+case "${1:-}" in
+-h | --help | help) printf "usage: %s [start|stop|restart] SERVICE\n" "$(basename "$0")" ;;
+start) __start "$2" ;;
+stop) __stop "$2" ;;
+restart) __restart "$2" ;;
+*)
+	svs=$(__list | menu -l10)
+	menu_exitcode=$?
+	__handle <<<"$svs"
+	;;
+esac
diff --git a/bin/secretmenu b/bin/secretmenu
index 8c447fb..0ae5e43 100755
--- a/bin/secretmenu
+++ b/bin/secretmenu
@@ -3,18 +3,17 @@
 set -eo pipefail
 [ -n "$DEBUG" ] && set -x
 
-ico=$(iconez -fs -n dialog-password-symbolic)
-trap '{ notify-send -a secretmenu -i "${ico}" -c error "secretmenu: failed :(" "<i>pipefail</i>"; exit 1; }' ERR
-
-secretmgr=rbw
-printpass=
-while getopts bpPh name; do
-	case ${name} in
+secretmgr=${_SECM_MGR:-rbw}
+printpass=${_SECM_PRINT:-}
+listandexit=
+while getopts bpPlh opt; do
+	case ${opt} in
 	b) secretmgr=rbw ;;
 	p) secretmgr=pass ;;
 	P) printpass=1 ;;
+	l) listandexit=1 ;;
 	h | ?)
-		echo "usage: secretmenu [-bp] [-P] [query]"
+		echo "usage: secretmenu [-bp] [-P] [-l] [query]"
 		echo
 		exit 2
 		;;
@@ -30,17 +29,12 @@ for tool in bemenu fd flock fzf $secretmgr; do
 	fi
 done
 
-# ensure only one menu runs at a time
-lockfile="$XDG_RUNTIME_DIR"/secretmenu.lock
-[ "$FLOCKER" != "$lockfile" ] && exec env FLOCKER="$lockfile" flock -ew 30 "$lockfile" "$0" "$@"
-trap '{ env UNSAFE=1 rm $lockfile 2>/dev/null || true; }' EXIT TERM INT
-
 __menu() {
 	if [ -t 1 ]; then
 		echo "terminal mode not implemented"
 		exit 1
 	fi
-	MENU_PROMPT="󰌆 secret" menu --list=10 --accept-single ${@:+--filter "$@"}
+	MENU_PROMPT="󰌆 secret" menu -l10 --accept-single ${@:+--filter "$@"}
 }
 
 if [ "$secretmgr" = "rbw" ] && command -v rbw >/dev/null 2>&1; then
@@ -70,12 +64,25 @@ if [ -n "$printpass" ]; then
 	}
 else
 	__handle() {
-		awk 'NR==1 {system("wl-copy -n " $0);hit+=1} /^Username:/ {system("wl-copy -n -p " $2);hit+=1} END{if(hit==0){print("no secret found") >/dev/stderr; exit(1);}}'
+		awk 'NR==1 {system("wl-copy -n \"" $0 "\"");hit+=1} /^Username: / {gsub("Username: ", "", $0); system("wl-copy -n -p \"" $0 "\"");hit+=1} END{if(hit==0){print("no secret found") >/dev/stderr; exit(1);}}'
 	}
 fi
 
 # main
 
+if [ -n "$listandexit" ]; then
+	__list_secrets
+	exit 0
+fi
+
+# ensure only one menu runs at a time
+lockfile="$XDG_RUNTIME_DIR"/secretmenu.lock
+[ "$FLOCKER" != "$lockfile" ] && exec env FLOCKER="$lockfile" _SECM_MGR="$secretmgr" _SECM_PRINT="$printpass" flock -ew 30 "$lockfile" "$0" "$@"
+trap '{ env UNSAFE=1 rm $lockfile 2>/dev/null || true; }' EXIT TERM INT
+
+ico=$(iconez -fs -n dialog-password-symbolic)
+trap '{ notify-send -a secretmenu -i "${ico}" -c error "secretmenu: failed :(" "<i>pipefail</i>"; exit 1; }' ERR
+
 pw=$({
 	__list_secrets
 	echo ">>pass"
@@ -100,12 +107,6 @@ if [ "$__ok" -eq 0 ]; then
 		-i "${ico}" \
 		'secretmenu: secret copied' \
 		'<i>will be removed after next paste</i>'
-else
-	notify-send \
-		-a passmenu \
-		-i "${ico}" \
-		-c error \
-		'secretmenu: failed :(' \
-		"<i>check stderr for details</i>"
-	exit 1
 fi
+
+exit "$__ok"
diff --git a/bin/soundswitch b/bin/soundswitch
index cc1de6c..080f4e0 100755
--- a/bin/soundswitch
+++ b/bin/soundswitch
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # DESCRIPTION:
 #  dmenu-based audio helper
@@ -37,16 +37,16 @@ volume_up=
 usage() {
 	printf "usage: %s [-hIOgfpHRmMvV]\n" "$(basename "$0")"
 	printf "\n"
-	printf "  -O \t(manipulate pulseaudio sinks)\n"
-	printf "  -I \t(manipulate pulseaudio sources)\n"
-	printf "  -g \t(set default sink and switch global output)\n"
-	printf "  -f \t(switch focused container output)\n"
+	printf "  -O \t(manipulate outputs)\n"
+	printf "  -I \t(manipulate inputs)\n"
+	printf "  -g \t(manipulate globally)\n"
+	# printf "  -f \t(manipulate focused container)\n"
 	printf "  -p \t(switch card profile)\n"
-	printf "  -H \t(switch card to HDMI profile)\n"
-	printf "  -R \t(switch card to default profile)\n"
+	# printf "  -H \t(switch card to HDMI profile)\n"
+	# printf "  -R \t(switch card to default profile)\n"
 	printf "\n"
-	printf "  -m \t(mute default sink)\n"
-	printf "  -M \t(mute default source)\n"
+	# printf "  -m \t(mute default sink)\n"
+	# printf "  -M \t(mute default source)\n"
 	printf "  -v \t(reduce sink volume by 5%%)\n"
 	printf "  -V \t(increase sink volume by 5%%)\n"
 	printf "\n"
@@ -95,52 +95,41 @@ done
 shift $((OPTIND - 1))
 
 # ask mode
-_mode_global="󰣨 global"
-_mode_focused="󰻿 focused"
-_mode_profile_card="󱂇 card profile"
-_mode_profile_hdmi="󰡁 hdmi profile"
-_mode_profile_reset="󰕍 reset profile"
-_mode_mute="󰂛 mute"
+_modes=(
+	"󰴸 output"
+	"󰍬 input"
+	"󱂇 profile"
+	# "󰻿 focused"
+	# "󰡁 hdmi profile"
+	# "󰕍 reset profile"
+	# "󰂛 mute"
+)
 if [ -z "$mode" ]; then
-	printf "$_mode_global\n$_mode_focused\n$_mode_profile_card\n$_mode_profile_hdmi\n$_mode_profile_reset\n$_mode_mute\n" | _menu | {
-		read -r line
-		case ${line} in
-		"$_mode_global") exec "$0" -g "$*" ;;
-		"$_mode_focused") exec "$0" -f "$*" ;;
-		"$_mode_profile_card") exec "$0" -p "$*" ;;
-		"$_mode_profile_hdmi") exec "$0" -H "$*" ;;
-		"$_mode_profile_reset") exec "$0" -R "$*" ;;
-		"$_mode_mute") exec "$0" -B "$*" ;;
-		*)
-			usage
-			;;
-		esac
-	}
-	exit $?
-fi
-
-_mode_output="󰴸 output"
-_mode_input="󰍬 input"
-if [ -n "$mode" ]; then
-	# ask target?
-	if [ -z "$output" ] && [ -z "$input" ]; then
-		printf "$_mode_output\n$_mode_input\n" | _menu | {
+	printf "%s\n" "${_modes[@]}" |
+		_menu |
+		{
 			read -r line
 			case ${line} in
-			"$_mode_output") exec "$0" -O $_args ;;
-			"$_mode_input") exec "$0" -I $_args ;;
-			*) usage ;;
+			"${_modes[0]}") exec "$0" -gO "$*" ;;
+			"${_modes[1]}") exec "$0" -gI "$*" ;;
+			"${_modes[2]}") exec "$0" -p "$*" ;;
+			# "${_modes[1]}") exec "$0" -f "$*" ;;
+			# "${_modes[3]}") exec "$0" -H "$*" ;;
+			# "${_modes[4]}") exec "$0" -R "$*" ;;
+			# "${_modes[5]}") exec "$0" -B "$*" ;;
+			*)
+				usage
+				;;
 			esac
 		}
-		exit $?
-	fi
+	exit $?
 fi
 
 # process quick actions first
 [ -n "$output" ] && [ -n "$mute" ] && exec pactl set-sink-mute '@DEFAULT_SINK@' toggle
 [ -n "$input" ] && [ -n "$mute" ] && exec pactl set-source-mute '@DEFAULT_SINK@' toggle
-[ -n "$volume_down" ] && exec pactl set-sink-volume '@DEFAULT_SINK@' '-5%'
-[ -n "$volume_up" ] && exec pactl set-sink-volume '@DEFAULT_SINK@' '+5%'
+[ -n "$volume_down" ] && exec pactl set-sink-volume '@DEFAULT_SINK@' '-2%'
+[ -n "$volume_up" ] && exec pactl set-sink-volume '@DEFAULT_SINK@' '+2%'
 
 [ -n "$output" ] && keyword="sink" && what="sink-input"
 [ -n "$input" ] && keyword="source" && what="source-output"
@@ -159,7 +148,7 @@ default() {
 #               e.g. {"i":60,"d":"Built-in Audio Analog Stereo"}
 __identifier_list() {
 	if [ "$1" = "card" ]; then
-		pactl --format=json list "${1}s" | jq -c '.[]|{i:.index,d:.properties["api.alsa.card.name"]}'
+		pactl --format=json list "${1}s" | jq -c '.[]|{i:.index,d:(.properties | .["device.alias"] // .["alsa.card_name"])}'
 	else
 		pactl --format=json list "${1}s" | jq -c '.[]|{i:.index,d:.description}'
 	fi
@@ -183,6 +172,9 @@ __identifier_fmt() {
 }
 __identifier_fmt_parse() {
 	fmt=$(cat)
+	if [ -z "${fmt}" ]; then
+		exit 1
+	fi
 	i=$(printf "%s" "$fmt" | tr -s ' ' | cut -d' ' -f1)
 	d=$(printf "%s" "$fmt" | tr -s ' ' | cut -d' ' -f2-)
 	jq -cn --arg i "$i" --arg d "$d" '{i:$i,d:$d}'
@@ -191,6 +183,7 @@ __identifier_fmt_parse() {
 selects() {
 	__identifier_list "$1" |
 		__identifier_fmt |
+		grep -v "Monitor of" |
 		_menu |
 		__identifier_fmt_parse
 }
@@ -208,11 +201,6 @@ json)
 	;;
 global)
 	target=$(selects "${keyword}")
-	if [ -z "${target}" ]; then
-		notif "focused" "no target ${what}" error
-		exit 1
-	fi
-
 	notif "global" "switch to <i>$(__identifier_desc "${target}")</i>"
 	# set new default
 	pactl "set-default-${keyword}" "$(__identifier_index "${target}")"
@@ -222,128 +210,117 @@ global)
 	exit $?
 	;;
 
-focused)
-	# parse pid of currently focused container
-	# then get the sink-inputs for it and parse the sink-input-id
-	notif "not implemented, do we need it?" error
-	exit 1
-
-	focused_binary=$(swq current con | jq -r '.pid' | xargs ps -o comm=)
-	what_id=$(printf "%s\n" "${focused_binary}" |
-		xargs pactl list "${what}s" |
-		tr '\n' '\r' |
-		perl -pe 's/[^\r]*index: ([0-9]+).+?application\.process\.binary = "([^\r]+)"\r.+?(?=index:|$)/\2=\1\r/g' |
-		tr '\r' '\n' |
-		grep "^{}" |
-		cut -d'=' -f2)
-	if [ -z "${what_id}" ]; then
-		notif "focused" "no ${what}" error
-		exit 1
-	fi
-
-	# select where to switch to
-	target=$(selects "${keyword}")
-	if [ -z "${target}" ]; then
-		exit 1
-	fi
-
-	notif "${focused_binary}" "switch to <i>${target}</i>"
-	pactl move-sink-input "${what_id}" "${target}"
-	exit $?
-	;;
-
+# focused)
+# 	# parse pid of currently focused container
+# 	# then get the sink-inputs for it and parse the sink-input-id
+# 	notif "not implemented, do we need it?" error
+# 	exit 1
+#
+# 	focused_binary=$(swq current con | jq -r '.pid' | xargs ps -o comm=)
+# 	what_id=$(printf "%s\n" "${focused_binary}" |
+# 		xargs pactl list "${what}s" |
+# 		tr '\n' '\r' |
+# 		perl -pe 's/[^\r]*index: ([0-9]+).+?application\.process\.binary = "([^\r]+)"\r.+?(?=index:|$)/\2=\1\r/g' |
+# 		tr '\r' '\n' |
+# 		grep "^{}" |
+# 		cut -d'=' -f2)
+# 	if [ -z "${what_id}" ]; then
+# 		notif "focused" "no ${what}" error
+# 		exit 1
+# 	fi
+#
+# 	# select where to switch to
+# 	target=$(selects "${keyword}")
+# 	if [ -z "${target}" ]; then
+# 		exit 1
+# 	fi
+#
+# 	notif "${focused_binary}" "switch to <i>${target}</i>"
+# 	pactl move-sink-input "${what_id}" "${target}"
+# 	exit $?
+# 	;;
+#
 profile)
-	notif "not implemented, do we need it?" "" error
-	exit 1
-
-	target_card=$(selects "card")
+	target_card=$(selects "card" | jq -r '.i')
 	if [ -z "${target_card}" ]; then
 		exit 1
 	fi
 
-	# [^\r]#([0-9]+).*?Name: ([^\r]+).*?Profiles:\r(.*?)Active.*?(?=Card #|$)
-	# target_profile=$(pactl list cards |
-	# 	tr '\n' '\r' |
-	# 	perl -pe 's/[^\r]#([0-9]+).*?Name: ([^\r]+).*?Profiles:\r(.*?)Active.*?(?=Card #|$)/\2~\3`/g' |
-	# 	tr -d '\t' |
-	# 	tr '`' '\n' |
-	# 	grep "${target_card}" |
-	# 	cut -d'~' -f2- |
-	# 	tr '\r' '\n' |
-	# 	xargs -L1 |
-	# 	_menu |
-	# 	perl -pe 's/^\s*([^\s]+):\s.*$/\1/')
-	# if [ -z "${target_profile}" ]; then
-	# 	exit 1
-	# fi
-	#
-	# notif "profile" "switch <i>${target_card}</i> to ${target_profile} profile"
-	# pactl set-card-profile "${target_card}" "${target_profile}"
-	# exit $?
-	;;
-
-hdmi)
-	notif "not implemented, do we need it?" "" error
-	exit 1
-
-	target_card=$(selects "card")
-	if [ -z "${target_card}" ]; then
-		exit 1
-	fi
-
-	target_profile=$(pactl list cards |
-		tr '\n' '\r' |
-		perl -pe 's/[^\r]#([0-9]+).*?Name: ([^\r]+).*?Profiles:\r(.*?)Active.*?(?=Card #|$)/\2~\3`/g' |
-		tr -d '\t' |
-		tr '`' '\n' |
-		grep "${target_card}" |
-		cut -d'~' -f2- |
-		tr '\r' '\n' |
-		grep -i "hdmi" |
-		grep -i -v "input" |
-		xargs -L1 |
-		_menu |
-		perl -pe 's/^\s*([^\s]+):\s.*$/\1/')
+	target_profile=$(
+		pactl --format=json list cards |
+			jq -cr --argjson idx "$target_card" '.[] | select(.index == $idx) | .profiles | keys[]' |
+			_menu
+	)
 	if [ -z "${target_profile}" ]; then
-		target_profile=${HDMI_PROFILE}
-	fi
-
-	notif "hdmi" "switch <i>${target_card}</i> to HDMI profile\n<i>${target_profile}</i>"
-	pactl set-card-profile "${target_card}" "${target_profile}"
-	exit $?
-	;;
-
-reset)
-	notif "not implemented, do we need it?" "" error
-	exit 1
-
-	target_card=$(selects "card")
-	if [ -z "${target_card}" ]; then
 		exit 1
 	fi
 
-	notif "reset" "switch <i>${target_card}</i> to default profile"
-	pactl set-card-profile "${target_card}" ${DEFAULT_PROFILE}
-	exit $?
-	;;
-
-mute)
-	notif "not implemented, do we need it?" "" error
-	exit 1
-
-	_data=$(pw-dump -N | jq -r '.. | select(.type?=="PipeWire:Interface:Node" and .info.props."media.class"?=="Stream/Output/Audio" and .info.props."stream.is-live"?==true) | @text')
-	_id=$(printf "${_data}" | jq -r '. | [ .info.props."application.name", .info.props."application.process.id", .id ] | @tsv' |
-		awk '{ system("swaymsg -t get_tree | jq -r \".. | select(.pid?==" $2 ") | .name\" | grep -v Picture-in-Picture | tr -d \"\\n\""); printf " [%s]", $3 }' |
-		_menu |
-		perl -pe 's/^.*\[([0-9]+)\]$/\1/')
-	if [ -z "${_id}" ]; then
-		exit 1
-	fi
-
-	_oid=$(printf "${_data}" | jq -r --argjson id "${_id}" '.. | select(.id?==$id) | .info.props."object.id"')
-	_target_state=$(printf "${_data}" | jq -r --argjson id "${_id}" '.. | select(.id?==$id) | .info.params.Props[0] | .mute = (.mute | not) | @text')
-	pw-cli set-param "${_oid}" Props "${_target_state}"
-	exit $?
+	notif "profile" "switch <i>${target_card}</i> to ${target_profile} profile"
+	pactl set-card-profile "${target_card}" "${target_profile}"
 	;;
 
+# hdmi)
+# 	notif "not implemented, do we need it?" "" error
+# 	exit 1
+#
+# 	target_card=$(selects "card")
+# 	if [ -z "${target_card}" ]; then
+# 		exit 1
+# 	fi
+#
+# 	target_profile=$(pactl list cards |
+# 		tr '\n' '\r' |
+# 		perl -pe 's/[^\r]#([0-9]+).*?Name: ([^\r]+).*?Profiles:\r(.*?)Active.*?(?=Card #|$)/\2~\3`/g' |
+# 		tr -d '\t' |
+# 		tr '`' '\n' |
+# 		grep "${target_card}" |
+# 		cut -d'~' -f2- |
+# 		tr '\r' '\n' |
+# 		grep -i "hdmi" |
+# 		grep -i -v "input" |
+# 		xargs -L1 |
+# 		_menu |
+# 		perl -pe 's/^\s*([^\s]+):\s.*$/\1/')
+# 	if [ -z "${target_profile}" ]; then
+# 		target_profile=${HDMI_PROFILE}
+# 	fi
+#
+# 	notif "hdmi" "switch <i>${target_card}</i> to HDMI profile\n<i>${target_profile}</i>"
+# 	pactl set-card-profile "${target_card}" "${target_profile}"
+# 	exit $?
+# 	;;
+#
+# reset)
+# 	notif "not implemented, do we need it?" "" error
+# 	exit 1
+#
+# 	target_card=$(selects "card")
+# 	if [ -z "${target_card}" ]; then
+# 		exit 1
+# 	fi
+#
+# 	notif "reset" "switch <i>${target_card}</i> to default profile"
+# 	pactl set-card-profile "${target_card}" ${DEFAULT_PROFILE}
+# 	exit $?
+# 	;;
+#
+# mute)
+# 	notif "not implemented, do we need it?" "" error
+# 	exit 1
+#
+# 	_data=$(pw-dump -N | jq -r '.. | select(.type?=="PipeWire:Interface:Node" and .info.props."media.class"?=="Stream/Output/Audio" and .info.props."stream.is-live"?==true) | @text')
+# 	_id=$(printf "${_data}" | jq -r '. | [ .info.props."application.name", .info.props."application.process.id", .id ] | @tsv' |
+# 		awk '{ system("swaymsg -t get_tree | jq -r \".. | select(.pid?==" $2 ") | .name\" | grep -v Picture-in-Picture | tr -d \"\\n\""); printf " [%s]", $3 }' |
+# 		_menu |
+# 		perl -pe 's/^.*\[([0-9]+)\]$/\1/')
+# 	if [ -z "${_id}" ]; then
+# 		exit 1
+# 	fi
+#
+# 	_oid=$(printf "${_data}" | jq -r --argjson id "${_id}" '.. | select(.id?==$id) | .info.props."object.id"')
+# 	_target_state=$(printf "${_data}" | jq -r --argjson id "${_id}" '.. | select(.id?==$id) | .info.params.Props[0] | .mute = (.mute | not) | @text')
+# 	pw-cli set-param "${_oid}" Props "${_target_state}"
+# 	exit $?
+# 	;;
+#
 esac