From 6be364d614b975b549d74702d0f85078662933bd Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 27 Oct 2020 14:13:59 +0000 Subject: [PATCH] initial commit --- window-select | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 window-select diff --git a/window-select b/window-select new file mode 100755 index 0000000..cb56952 --- /dev/null +++ b/window-select @@ -0,0 +1,32 @@ +#!/bin/bash + +# dependency - xtitle + +# arguments: +# none - select from windows on current desktop +# 'monitor' - select from all windows. +# 'all' - select from all windows. + +. "$HOME/.config/dmenu/dmenurc" + +if command -v bspc ; then + # adapted from: https://www.reddit.com/r/bspwm/comments/er2olp/dmenu_window_picker/ff16ff0/ + # NOTE: query can be '.window', '.local.window', '.local.tiled' (to only have tiled windows + # as options) or '.local.window.!fullscreen.!floating' (to only have tiled and pseudo_tiled windows as options). + if [ "$1" = all ] ; then + ids=($(bspc query -N -n ".window")) + elif [ "$1" = monitor ] ; then + ids=($(bspc query -N -m "focused")) + else + # current desktop + ids=($(bspc query -N -n ".local.window")) + fi + options="$(xtitle "${ids[@]}" | awk '{ print ++i": "$0 }')" + + [[ -n "$options" ]] || exit + + id_index="$(<<< "$options" dmenu $DMENU_OPTIONS -l 20 | cut -d: -f1)" + [[ -n "$id_index" ]] || exit + bspc node "${ids[$((id_index - 1))]}" -f + +fi