summaryrefslogtreecommitdiffstats
path: root/bin/hornet/kill-focused
diff options
context:
space:
mode:
Diffstat (limited to 'bin/hornet/kill-focused')
-rwxr-xr-xbin/hornet/kill-focused49
1 files changed, 0 insertions, 49 deletions
diff --git a/bin/hornet/kill-focused b/bin/hornet/kill-focused
deleted file mode 100755
index 37271ac..0000000
--- a/bin/hornet/kill-focused
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-use 5.014;
-
-use JSON::PP;
-
-my ($sig) = @ARGV;
-my $pid = get_pid();
-my $pgrp = get_pgrp($pid);
-kill $sig, -$pgrp;
-
-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`;
- die "couldn't get pid from focused window"
- if $prop =~ /not found/;
- chomp($prop);
- $prop =~ s/^_NET_WM_PID\(CARDINAL\) = //;
- return $prop;
-}
-
-sub get_pgrp {
- my ($pid) = @_;
- open my $stat_fh, '<', "/proc/$pid/stat"
- or die "couldn't open /proc/$pid/stat";
- my $stat = do { local $/; <$stat_fh> };
- my @f = ($stat =~ /\([^)]*\)|[^ ]+/g);
- return $f[4];
-}
-
-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;
-}