|
|
@ -1,6 +1,7 @@
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p /tmp/tdrop
|
|
|
|
MUTDROP_PATH=/tmp/tdrop_"$USER"
|
|
|
|
|
|
|
|
mkdir -p "$MUTDROP_PATH" -m 700
|
|
|
|
|
|
|
|
|
|
|
|
print_help() {
|
|
|
|
print_help() {
|
|
|
|
echo "
|
|
|
|
echo "
|
|
|
@ -125,19 +126,19 @@ program=$1
|
|
|
|
if [[ $# -ne 1 ]]; then
|
|
|
|
if [[ $# -ne 1 ]]; then
|
|
|
|
echo >&2 "Exactly 1 positional argument is required." \
|
|
|
|
echo >&2 "Exactly 1 positional argument is required." \
|
|
|
|
"For help use -h or --help or see the manpage." | \
|
|
|
|
"For help use -h or --help or see the manpage." | \
|
|
|
|
tee -a /tmp/tdrop/log
|
|
|
|
tee -a "$MUTDROP_PATH"/log
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# validate options that require number values
|
|
|
|
# validate options that require number values
|
|
|
|
if [[ ! $height$width$xoff$yoff =~ ^[0-9%-]*$ ]]; then
|
|
|
|
if [[ ! $height$width$xoff$yoff =~ ^[0-9%-]*$ ]]; then
|
|
|
|
echo >&2 "The -h, -w, -x, and -y values must be numbers (or percentages)." | \
|
|
|
|
echo >&2 "The -h, -w, -x, and -y values must be numbers (or percentages)." | \
|
|
|
|
tee -a /tmp/tdrop/log
|
|
|
|
tee -a "$MUTDROP_PATH"/log
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ -n $dec_fix ]] && [[ ! $dec_fix =~ ^-?[0-9]+x-?[0-9]+$ ]]; then
|
|
|
|
if [[ -n $dec_fix ]] && [[ ! $dec_fix =~ ^-?[0-9]+x-?[0-9]+$ ]]; then
|
|
|
|
echo >&2 "The decoration fix value must have form 'num'x'num'." \
|
|
|
|
echo >&2 "The decoration fix value must have form 'num'x'num'." \
|
|
|
|
"The numbers can be negative or zero." | tee -a /tmp/tdrop/log
|
|
|
|
"The numbers can be negative or zero." | tee -a "$MUTDROP_PATH"/log
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
@ -270,8 +271,8 @@ update_geometry_settings_for_monitor() {
|
|
|
|
|
|
|
|
|
|
|
|
# determine if monitor has changed and save current monitor
|
|
|
|
# determine if monitor has changed and save current monitor
|
|
|
|
local last_monitor
|
|
|
|
local last_monitor
|
|
|
|
last_monitor=$(< /tmp/tdrop/last_monitor) 2> /dev/null
|
|
|
|
last_monitor=$(< "$MUTDROP_PATH"/last_monitor) 2> /dev/null
|
|
|
|
echo "$current_monitor" > /tmp/tdrop/last_monitor
|
|
|
|
echo "$current_monitor" > "$MUTDROP_PATH"/last_monitor
|
|
|
|
if [[ $current_monitor != "$last_monitor" ]]; then
|
|
|
|
if [[ $current_monitor != "$last_monitor" ]]; then
|
|
|
|
monitor_changed=true
|
|
|
|
monitor_changed=true
|
|
|
|
fi
|
|
|
|
fi
|
|
|
@ -477,8 +478,8 @@ run_map_hook() {
|
|
|
|
|
|
|
|
|
|
|
|
maybe_cancel_auto_show() {
|
|
|
|
maybe_cancel_auto_show() {
|
|
|
|
if $cancel_auto_show && \
|
|
|
|
if $cancel_auto_show && \
|
|
|
|
[[ $1 == $(cat /tmp/tdrop/auto_hidden/wid 2> /dev/null) ]]; then
|
|
|
|
[[ $1 == $(cat "$MUTDROP_PATH"/auto_hidden/wid 2> /dev/null) ]]; then
|
|
|
|
> /tmp/tdrop/auto_hidden/wid
|
|
|
|
> "$MUTDROP_PATH"/auto_hidden/wid
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -555,7 +556,7 @@ program_start() {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
wid=$(create_win_return_wid "$program_command")
|
|
|
|
wid=$(create_win_return_wid "$program_command")
|
|
|
|
echo "$wid" > /tmp/tdrop/"$program$num"
|
|
|
|
echo "$wid" > "$MUTDROP_PATH"/"$program$num"
|
|
|
|
# only will work if a pre-command has been run (e.g. bspwm)
|
|
|
|
# only will work if a pre-command has been run (e.g. bspwm)
|
|
|
|
xdotool windowmove "$wid" "$xoff" "$yoff" \
|
|
|
|
xdotool windowmove "$wid" "$xoff" "$yoff" \
|
|
|
|
windowsize "$wid" "$width" "$height"
|
|
|
|
windowsize "$wid" "$width" "$height"
|
|
|
@ -566,8 +567,8 @@ current_create() {
|
|
|
|
# turns active window into a dropdown
|
|
|
|
# turns active window into a dropdown
|
|
|
|
local wid
|
|
|
|
local wid
|
|
|
|
wid=$(xdotool getactivewindow)
|
|
|
|
wid=$(xdotool getactivewindow)
|
|
|
|
echo "$wid" > /tmp/tdrop/current"$num"
|
|
|
|
echo "$wid" > "$MUTDROP_PATH"/current"$num"
|
|
|
|
get_class_name "$wid" > /tmp/tdrop/current"$num"_type
|
|
|
|
get_class_name "$wid" > "$MUTDROP_PATH"/current"$num"_type
|
|
|
|
echo -n "$wid"
|
|
|
|
echo -n "$wid"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -582,7 +583,7 @@ wid_toggle() {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# get saved window id if already created
|
|
|
|
# get saved window id if already created
|
|
|
|
local wid exists visibility
|
|
|
|
local wid exists visibility
|
|
|
|
wid=$(< /tmp/tdrop/"$program$num") 2> /dev/null
|
|
|
|
wid=$(< "$MUTDROP_PATH"/"$program$num") 2> /dev/null
|
|
|
|
exists=true
|
|
|
|
exists=true
|
|
|
|
if [[ -n $wid ]]; then
|
|
|
|
if [[ -n $wid ]]; then
|
|
|
|
visibility=$(get_visibility "$wid")
|
|
|
|
visibility=$(get_visibility "$wid")
|
|
|
@ -590,7 +591,7 @@ wid_toggle() {
|
|
|
|
if [[ -z $visibility ]] || [[ -z $(xprop -id "$wid" 2> /dev/null) ]]; then
|
|
|
|
if [[ -z $visibility ]] || [[ -z $(xprop -id "$wid" 2> /dev/null) ]]; then
|
|
|
|
# window no longer exists
|
|
|
|
# window no longer exists
|
|
|
|
exists=false
|
|
|
|
exists=false
|
|
|
|
> /tmp/tdrop/"$program$num"
|
|
|
|
> "$MUTDROP_PATH"/"$program$num"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
else
|
|
|
|
exists=false
|
|
|
|
exists=false
|
|
|
@ -602,7 +603,7 @@ wid_toggle() {
|
|
|
|
xdotool set_desktop_for_window "$wid" "$(xdotool get_desktop)"
|
|
|
|
xdotool set_desktop_for_window "$wid" "$(xdotool get_desktop)"
|
|
|
|
if [[ $(get_visibility "$wid") == IsUnMapped ]]; then
|
|
|
|
if [[ $(get_visibility "$wid") == IsUnMapped ]]; then
|
|
|
|
if [[ $program == current ]]; then
|
|
|
|
if [[ $program == current ]]; then
|
|
|
|
map_pre_command "$(< /tmp/tdrop/current"$num"_type)"
|
|
|
|
map_pre_command "$(< \"$MUTDROP_PATH\"/current\"$num\"_type)"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
map_pre_command "$program"
|
|
|
|
map_pre_command "$program"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
@ -712,7 +713,7 @@ get_geometry() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
give_geometry() {
|
|
|
|
give_geometry() {
|
|
|
|
eval "$(< /tmp/tdrop/auto_hidden/geometry)"
|
|
|
|
eval "$(< \"$MUTDROP_PATH\"/auto_hidden/geometry)"
|
|
|
|
local x_fix y_fix X Y
|
|
|
|
local x_fix y_fix X Y
|
|
|
|
if [[ -n $dec_fix ]]; then
|
|
|
|
if [[ -n $dec_fix ]]; then
|
|
|
|
x_fix=$(echo "$dec_fix" | awk -F "x" '{print $1}')
|
|
|
|
x_fix=$(echo "$dec_fix" | awk -F "x" '{print $1}')
|
|
|
@ -734,12 +735,12 @@ set_geometry() {
|
|
|
|
|
|
|
|
|
|
|
|
toggle_auto_hide() {
|
|
|
|
toggle_auto_hide() {
|
|
|
|
local no_hide
|
|
|
|
local no_hide
|
|
|
|
no_hide=$(< /tmp/tdrop/auto_hidden/no_hide) 2> /dev/null
|
|
|
|
no_hide=$(< "$MUTDROP_PATH"/auto_hidden/no_hide) 2> /dev/null
|
|
|
|
mkdir -p /tmp/tdrop/auto_hidden
|
|
|
|
mkdir -p "$MUTDROP_PATH"/auto_hidden
|
|
|
|
if [[ -z $no_hide ]]; then
|
|
|
|
if [[ -z $no_hide ]]; then
|
|
|
|
echo "true" > /tmp/tdrop/auto_hidden/no_hide
|
|
|
|
echo "true" > "$MUTDROP_PATH"/auto_hidden/no_hide
|
|
|
|
else
|
|
|
|
else
|
|
|
|
> /tmp/tdrop/auto_hidden/no_hide
|
|
|
|
> "$MUTDROP_PATH"/auto_hidden/no_hide
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -749,26 +750,26 @@ toggle_auto_hide() {
|
|
|
|
|
|
|
|
|
|
|
|
auto_hide() {
|
|
|
|
auto_hide() {
|
|
|
|
local no_hide
|
|
|
|
local no_hide
|
|
|
|
no_hide=$(< /tmp/tdrop/auto_hidden/no_hide) 2> /dev/null
|
|
|
|
no_hide=$(< "$MUTDROP_PATH"/auto_hidden/no_hide) 2> /dev/null
|
|
|
|
if [[ -z $no_hide ]]; then
|
|
|
|
if [[ -z $no_hide ]]; then
|
|
|
|
local wid
|
|
|
|
local wid
|
|
|
|
wid=$(xdotool getactivewindow)
|
|
|
|
wid=$(xdotool getactivewindow)
|
|
|
|
mkdir -p /tmp/tdrop/auto_hidden
|
|
|
|
mkdir -p "$MUTDROP_PATH"/auto_hidden
|
|
|
|
echo "$wid" > /tmp/tdrop/auto_hidden/wid
|
|
|
|
echo "$wid" > "$MUTDROP_PATH"/auto_hidden/wid
|
|
|
|
get_class_name "$wid" > /tmp/tdrop/auto_hidden/class
|
|
|
|
get_class_name "$wid" > "$MUTDROP_PATH"/auto_hidden/class
|
|
|
|
get_geometry "$wid" > /tmp/tdrop/auto_hidden/geometry
|
|
|
|
get_geometry "$wid" > "$MUTDROP_PATH"/auto_hidden/geometry
|
|
|
|
xdotool windowunmap "$wid"
|
|
|
|
xdotool windowunmap "$wid"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto_show() {
|
|
|
|
auto_show() {
|
|
|
|
local no_hide
|
|
|
|
local no_hide
|
|
|
|
no_hide=$(< /tmp/tdrop/auto_hidden/no_hide) 2> /dev/null
|
|
|
|
no_hide=$(< "$MUTDROP_PATH"/auto_hidden/no_hide) 2> /dev/null
|
|
|
|
if [[ -z $no_hide ]]; then
|
|
|
|
if [[ -z $no_hide ]]; then
|
|
|
|
local wid class was_floating
|
|
|
|
local wid class was_floating
|
|
|
|
wid=$(< /tmp/tdrop/auto_hidden/wid)
|
|
|
|
wid=$(< "$MUTDROP_PATH"/auto_hidden/wid)
|
|
|
|
class=$(< /tmp/tdrop/auto_hidden/class)
|
|
|
|
class=$(< "$MUTDROP_PATH"/auto_hidden/class)
|
|
|
|
was_floating=$(< /tmp/tdrop/auto_hidden/geometry)
|
|
|
|
was_floating=$(< "$MUTDROP_PATH"/auto_hidden/geometry)
|
|
|
|
if [[ $was_floating != false ]]; then
|
|
|
|
if [[ $was_floating != false ]]; then
|
|
|
|
map_pre_command "$class"
|
|
|
|
map_pre_command "$class"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
@ -806,7 +807,7 @@ if $auto_detect_wm; then
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if $clearwid; then
|
|
|
|
if $clearwid; then
|
|
|
|
> /tmp/tdrop/"$program$num"
|
|
|
|
> "$MUTDROP_PATH"/"$program$num"
|
|
|
|
elif [[ $program == toggle_auto_hide ]]; then
|
|
|
|
elif [[ $program == toggle_auto_hide ]]; then
|
|
|
|
toggle_auto_hide
|
|
|
|
toggle_auto_hide
|
|
|
|
elif [[ $program == auto_hide ]]; then
|
|
|
|
elif [[ $program == auto_hide ]]; then
|
|
|
|