From b138d2c3b3cdf4eeda8bca3fffe296bebf946196 Mon Sep 17 00:00:00 2001 From: angelic-sedition Date: Sat, 14 Feb 2015 13:41:16 -0500 Subject: [PATCH] get rid of repetitive code for getting class name --- tdrop | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tdrop b/tdrop index 5507c33..b884ad7 100755 --- a/tdrop +++ b/tdrop @@ -80,6 +80,10 @@ do esac done +get_class_name() { + xprop -id "$(xprop -root _NET_ACTIVE_WINDOW | awk '{print $5}')" WM_CLASS | awk '{ gsub(/"/, ""); print $4}' +} + float_pre_command() { if [[ -n $float_pre ]]; then if [[ $float_pre == bspwm ]]; then @@ -131,7 +135,7 @@ current_create() { # turns active window into a dropdown wid=$(xdotool getactivewindow) echo "$wid" > /tmp/tdrop/current"$num" - xprop -id "$(xprop -root _NET_ACTIVE_WINDOW | awk '{print $5}')" WM_CLASS | awk '{ gsub(/"/, ""); print $4}' > /tmp/tdrop/current"$num"_type + get_class_name > /tmp/tdrop/current"$num"_type } wid_toggle() { @@ -179,10 +183,9 @@ auto_hide() { no_hide=$(< /tmp/tdrop/auto_hidden/no_hide) if [[ -z $no_hide ]]; then wid=$(xdotool getactivewindow) - class_name=$(xprop -id "$(xprop -root _NET_ACTIVE_WINDOW | awk '{print $5}')" WM_CLASS | awk '{ gsub(/"/, ""); print $4}') mkdir -p /tmp/tdrop/auto_hidden echo "$wid" > /tmp/tdrop/auto_hidden/wid - echo "$class_name" > /tmp/tdrop/auto_hidden/class + get_class_name > /tmp/tdrop/auto_hidden/class xdotool windowunmap "$wid" fi }