Add -f option to specify options for the terminal or other program to

be created using

Addresses #6
long-opts
noctuid 9 years ago
parent 8eed440432
commit b21f9b8add

26
tdrop

@ -23,6 +23,7 @@ options:
-d XxY give decoration/border size to accurately save position; only applicable with auto_show; on applicable with a few window managers (e.g. blackbox) -d XxY give decoration/border size to accurately save position; only applicable with auto_show; on applicable with a few window managers (e.g. blackbox)
-z use a different sleep time to wait for terminal to be created (advanced; see man page) -z use a different sleep time to wait for terminal to be created (advanced; see man page)
-Z use a different sleep time for -W program to be created (advanced; see man page) -Z use a different sleep time for -W program to be created (advanced; see man page)
-f specify flags/options to be used when creating the term or window (e.g. -f '--title mytitle', default: none)
-a automatically detect window manager and if settings exist for it, automatically set -p, -P, and -d values as necessary; this can have affect when used with a terminal or with auto_show or auto_hide (default: false) -a automatically detect window manager and if settings exist for it, automatically set -p, -P, and -d values as necessary; this can have affect when used with a terminal or with auto_show or auto_hide (default: false)
-m for use with multiple monitors and only with dropdowns (not for auto_show or auto_hide); convert percentages used for width or height to values relative to the size of the current monitor and force reszing of the dropdown when the monitor changes (default: false) -m for use with multiple monitors and only with dropdowns (not for auto_show or auto_hide); convert percentages used for width or height to values relative to the size of the current monitor and force reszing of the dropdown when the monitor changes (default: false)
-W the given program is not a terminal (or lacks an -e flag) (default: assume it IS a terminal) -W the given program is not a terminal (or lacks an -e flag) (default: assume it IS a terminal)
@ -60,13 +61,14 @@ sleep_term_time=0.01
sleep_term_user_set=false sleep_term_user_set=false
sleep_win_time=0.5 sleep_win_time=0.5
sleep_win_user_set=false sleep_win_user_set=false
program_flags=""
normal_window=false normal_window=false
clearwid=false clearwid=false
cancel_auto_show=true cancel_auto_show=true
term=${*:0-1} term=${*:0-1}
auto_detect_wm=false auto_detect_wm=false
multiple_monitors=false multiple_monitors=false
while getopts :h:w:x:y:s:n:p:P:M:O:d:z:Z:-:Wam opt while getopts :h:w:x:y:s:n:p:P:M:O:d:z:Z:f:-:Wam opt
do do
case $opt in case $opt in
h) height=$OPTARG;; h) height=$OPTARG;;
@ -84,6 +86,7 @@ do
sleep_term_user_set=true;; sleep_term_user_set=true;;
Z) sleep_win_time=$OPTARG Z) sleep_win_time=$OPTARG
sleep_win_user_set=true;; sleep_win_user_set=true;;
f) program_flags=$OPTARG;;
W) normal_window=true;; W) normal_window=true;;
a) auto_detect_wm=true;; a) auto_detect_wm=true;;
m) multiple_monitors=true;; m) multiple_monitors=true;;
@ -106,6 +109,7 @@ do
sleep_term_user_set=true;; sleep_term_user_set=true;;
sleep-window) sleep_win_time=$OPTARG sleep-window) sleep_win_time=$OPTARG
sleep_win_user_set=true;; sleep_win_user_set=true;;
program-flags) program_flags=$OPTARG;;
normal-window) normal_window=true;; normal-window) normal_window=true;;
auto-detect-wm) auto_detect_wm=true;; auto-detect-wm) auto_detect_wm=true;;
multiple-monitors) multiple_monitors=true;; multiple-monitors) multiple_monitors=true;;
@ -386,27 +390,37 @@ maybe_cancel_auto_show() {
# #
term_create() { term_create() {
if [[ -n $program_flags ]]; then
term_command="$term $program_flags"
else
term_command=$term
fi
if [[ -n $session_name ]]; then if [[ -n $session_name ]]; then
# ugly workarounds due to how different terms different -e flags work # ugly workarounds due to how different terms different -e flags work
if [[ $term == urxvt ]]; then if [[ $term == urxvt ]]; then
$term -e bash -c "sleep $sleep_term_time && xdotool getactivewindow > /tmp/tdrop/$term$num && xdotool getactivewindow windowmove $xoff $yoff windowsize $width $height && tmux attach-session -dt $session_name || tmuxinator start $session_name || tmux new-session -s $session_name" & $term_command -e bash -c "sleep $sleep_term_time && xdotool getactivewindow > /tmp/tdrop/$term$num && xdotool getactivewindow windowmove $xoff $yoff windowsize $width $height && tmux attach-session -dt $session_name || tmuxinator start $session_name || tmux new-session -s $session_name" &
else else
# starting with '/bin/bash -c' because required by termite # starting with '/bin/bash -c' because required by termite
$term -e "/bin/bash -c 'sleep $sleep_term_time && xdotool getactivewindow > /tmp/tdrop/$term$num && xdotool getactivewindow windowmove $xoff $yoff windowsize $width $height && tmux attach-session -dt $session_name || tmuxinator start $session_name || tmux new-session -s $session_name'" & $term_command -e "/bin/bash -c 'sleep $sleep_term_time && xdotool getactivewindow > /tmp/tdrop/$term$num && xdotool getactivewindow windowmove $xoff $yoff windowsize $width $height && tmux attach-session -dt $session_name || tmuxinator start $session_name || tmux new-session -s $session_name'" &
fi fi
else else
# not using hold, because flag is different for different terminals # not using hold, because flag is different for different terminals
if [[ $term == urxvt ]]; then if [[ $term == urxvt ]]; then
$term -e bash -c "sleep $sleep_term_time && xdotool getactivewindow > /tmp/tdrop/$term$num && xdotool getactivewindow windowmove $xoff $yoff windowsize $width $height && $SHELL" & $term_command -e bash -c "sleep $sleep_term_time && xdotool getactivewindow > /tmp/tdrop/$term$num && xdotool getactivewindow windowmove $xoff $yoff windowsize $width $height && $SHELL" &
else else
# not using hold, because flag is different for different terminals # not using hold, because flag is different for different terminals
$term -e "/bin/bash -c 'sleep $sleep_term_time && xdotool getactivewindow > /tmp/tdrop/$term$num && xdotool getactivewindow windowmove $xoff $yoff windowsize $width $height && $SHELL'" & $term_command -e "/bin/bash -c 'sleep $sleep_term_time && xdotool getactivewindow > /tmp/tdrop/$term$num && xdotool getactivewindow windowmove $xoff $yoff windowsize $width $height && $SHELL'" &
fi fi
fi fi
} }
win_create() { win_create() {
$term & if [[ -n $program_flags ]]; then
win_command="$term $program_flags"
else
win_command=$term
fi
$win_command &
# need to wait for window to be created # need to wait for window to be created
sleep $sleep_win_time sleep $sleep_win_time
# often pids have two wids # often pids have two wids

@ -57,6 +57,9 @@ Specify an alternate sleep time to wait for a terminal emulator to be completed.
\fB\-Z\fR, \fB \-\-sleep-window\fR \fB\-Z\fR, \fB \-\-sleep-window\fR
Specify an alternate sleep time to wait for a window to be completed. This is for use with -W or for -a with tiling window managers that cannot pre-float the next instance of a window (e.g. awesome and i3 if no rule to always float a specific class). Only use this option if tdrop ends up capturing a different window as the dropdown when you press a dropdown key. You probably won't need to change this, and if you do, please report it. I hope to remove the need for sleeping entirely in the future. (default: 0.5) Specify an alternate sleep time to wait for a window to be completed. This is for use with -W or for -a with tiling window managers that cannot pre-float the next instance of a window (e.g. awesome and i3 if no rule to always float a specific class). Only use this option if tdrop ends up capturing a different window as the dropdown when you press a dropdown key. You probably won't need to change this, and if you do, please report it. I hope to remove the need for sleeping entirely in the future. (default: 0.5)
.TP .TP
\fB\-f\fR, \fB \-\-program-flags\fR
Specify flags/options that the terminal or program should be called with. For example, to set the title of the terminal, something like '-f "--title mytitle"' can be used. (default: none)
.TP
\fB\-W\fR, \fB \-\-normal-window\fR \fB\-W\fR, \fB \-\-normal-window\fR
Specifies that the program is not a terminal or does not have the '-e' flag; takes no argument. If using 'tdrop current', this option will have no effect either way. (default: false) Specifies that the program is not a terminal or does not have the '-e' flag; takes no argument. If using 'tdrop current', this option will have no effect either way. (default: false)
.TP .TP

Loading…
Cancel
Save