diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-03-21 18:29:49 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-03-21 18:33:26 -0400 |
commit | e47bb478647d383635797926433339c82c53fc27 (patch) | |
tree | a6a4dd3cdb6a067d7cbcda0a5be345f16f60dacc | |
parent | d319a3b9598cf0abceb7241e6bebeb5c9ae9698c (diff) | |
download | conf-e47bb478647d383635797926433339c82c53fc27.tar.gz conf-e47bb478647d383635797926433339c82c53fc27.zip |
add script to suspend and resume X processes
-rwxr-xr-x | bin/kill_focused | 36 | ||||
-rw-r--r-- | xbindkeysrc | 6 |
2 files changed, 42 insertions, 0 deletions
diff --git a/bin/kill_focused b/bin/kill_focused new file mode 100755 index 0000000..b1f8d05 --- /dev/null +++ b/bin/kill_focused @@ -0,0 +1,36 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use JSON; + +my ($sig) = @ARGV; +my $pid = get_pid(); +kill $sig, $pid; + +sub get_pid { + my $window_id = get_window_id(); + die "couldn't find window" unless defined $window_id; + my $prop = `xprop -id $window_id _NET_WM_PID`; + chomp($prop); + $prop =~ s/^_NET_WM_PID\(CARDINAL\) = //; + return $prop; +} + +sub get_window_id { + return find(decode_json(`i3-msg -t get_tree`))->{window}; +} + +sub find { + my ($t) = @_; + if ($t->{focused}) { + return $t; + } + + for my $subtree (@{ $t->{nodes} }, @{ $t->{floating_nodes} }) { + my $found = find($subtree); + return $found if $found; + } + + return; +} diff --git a/xbindkeysrc b/xbindkeysrc index 1c128f2..677aed7 100644 --- a/xbindkeysrc +++ b/xbindkeysrc @@ -38,4 +38,10 @@ XF86Display "xset dpms force off" + XF86Search + +"kill_focused STOP" XF86Launch3 + +"kill_focused CONT" + XF86Launch4 |