Skip to content

Instantly share code, notes, and snippets.

@alvaro-jmp
Last active December 10, 2023 03:14
Show Gist options
  • Select an option

  • Save alvaro-jmp/a07eb7b9ddc037044fe737885d0dd766 to your computer and use it in GitHub Desktop.

Select an option

Save alvaro-jmp/a07eb7b9ddc037044fe737885d0dd766 to your computer and use it in GitHub Desktop.
This is another simpler and similar script to dmenu_launcher_wmctrl.sh (https://gist.github.com/alvaro-jmp/3a0b1ae132780a56c6b0838e290471c2) using dmenu_path to get a list of the binaries or shell scripts, wmctrl to get the information about the windows.
#!/bin/bash
# This is another simpler and similar script to dmenu_launcher_wmctrl.sh (https://gist.github.com/alvaro-jmp/3a0b1ae132780a56c6b0838e290471c2) using compgen to get a list of the binaries or shell scripts, wmctrl to get the information about the windows.
# Print the list of binaries or shell scripts and windows in dmenu
result=$(printf "%s\n%s" "$(wmctrl -l | sort -nk2 | awk '{print "WIN ###", $0}')" "$(compgen -c | awk '{print "RUN >>>", $0}')" | dmenu -l 10)
# To switch between windows
if [[ "$result" =~ ^WIN ]]; then
echo $result | awk '{print $3}' | xargs wmctrl -i -a
# To run applications
elif [[ "$result" =~ ^RUN ]]; then
run=$(echo $result | sed "s/^RUN >>>//")
/bin/bash -c "$run &"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment