Skip to content

Instantly share code, notes, and snippets.

@JayGoldberg
Last active April 11, 2017 15:11
Show Gist options
  • Save JayGoldberg/e10ff418ac98c27fdfda3e3d41f18643 to your computer and use it in GitHub Desktop.
Save JayGoldberg/e10ff418ac98c27fdfda3e3d41f18643 to your computer and use it in GitHub Desktop.
LINUX: Find all executables in $PATH that are likely XWindows (GUI) applications
#!/bin/bash
## @author Jay Goldberg
## @email jaymgoldberg@gmail.com
## @license Apache 2.0
## @description Find all executables in $PATH that are likely XWindows (GUI) applications
## @usage findXapps.sh
#=======================================================================
# a substring of the dynamically linked library that determines if the exe is an X app
library="libX"
#library="xcb"
testbin() {
if [[ $(ldd "$1" | grep -i "$library") ]]; then echo "$1";fi
}
# make it available to the bash invocation that happens next
export -f testbin
export library
# this path split does not work with paths that have spaces :(
for path in $(echo $PATH | tr ':' ' '); do
find "$path" -executable -type f -exec bash -c 'testbin "{}"' \;
done
unset -f testbin
unset library
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment