Last active
June 19, 2019 16:24
-
-
Save tyjak/8e27c6053a0daf306475a33c0d76c643 to your computer and use it in GitHub Desktop.
popup pour i3 manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# popup | |
# wrapper to create popup window in i3w | |
# dependancies: i3w, termite | |
# add this in your i3 config file : | |
# set $wfM_height 600 | |
# set $wfM_width 1000 | |
# for_window [class="w_float-notitle-medium-sticky"] border 1pixel, floating enable, resize set $wfL_width $wfL_height, move position center, sticky enable | |
# for_window [class="w_float-notitle-medium"] border 1pixel, floating enable, resize set $wfL_width $wfL_height, move position center | |
# for_window [class="w_float-notitle-sticky"] border 1pixel, floating enable, move position center, sticky enable | |
# for_window [class="w_float-notitle"] border 1pixel, floating enable, move position center | |
while getopts t:s:Sfe:d o | |
do case "$o" in | |
t) options="--title $OPTARG" | |
title=${OPTARG};; | |
s) windowsize="-${OPTARG}";; | |
S) windowsticky="-sticky";; | |
f) foreground=' && sleep infinity';; | |
e) bin=${OPTARG};; | |
d) debug=1;; | |
[?]) print >&2 "Usage: $0 [-t (window title)] [-s medium] [-S] [-f] [-e command]" | |
exit 1;; | |
esac | |
done | |
bin_cleaned=${bin%% *} | |
is_running=$( ps -eo cmd | grep -c "^termite --title=${title:-${bin_cleaned}}" ) | |
#TODO try to simplify popup run test | |
#is_running=$(pgrep $bin_cleaned | wc -l) | |
if [ ${debug} ] | |
then | |
echo "bin cleaned: $bin_cleaned" | |
echo "is running: $is_running ($( ps -eo cmd | grep "termite --title=${title:-${bin_cleaned}}"))" | |
echo "pgrep $bin_cleaned: $(pgrep $bin_cleaned | wc -l)" | |
echo "title: ${title:-${bin_cleaned}}" | |
echo "bin: ${bin}${foreground}" | |
echo "i3-msg: i3-msg -t command \"exec termite --title=\"${title:-${bin_cleaned}}\" --class=w_float-notitle${windowsize}${windowsticky} -e '${bin}${foreground}'\"" | |
fi | |
if [ ${is_running} -eq 0 ] | |
then | |
i3-msg -t command "exec termite --title=\"${title:-${bin_cleaned}}\" --class=w_float-notitle${windowsize}${windowsticky} -e 'sh -c \"${bin}${foreground}\"'" | |
else | |
i3-msg -t command '[title="'${title:-${bin_cleaned}}'"] kill' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment