diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2021-03-09 17:13:10 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2021-03-09 17:13:10 +0100 |
commit | f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45 (patch) | |
tree | 65587b92e729f3d5b46aecc698ba0649898228b4 /.local/bin/dmkill | |
parent | new script (diff) | |
download | dotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.tar.gz dotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.tar.bz2 dotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.tar.xz dotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.tar.zst dotfiles-bsd-f3a02b2ceec9cabc4bdde0426ec0d5c084f69b45.zip |
new scripts
Diffstat (limited to '')
-rwxr-xr-x | .local/bin/dmkill | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/.local/bin/dmkill b/.local/bin/dmkill new file mode 100755 index 0000000..87c91fd --- /dev/null +++ b/.local/bin/dmkill @@ -0,0 +1,60 @@ +#!/usr/local/bin/perl + +use strict; +use warnings; +use File::HomeDir qw(home); +use constant CONFIRM => [ + "No", + "Yes" + ]; + +sub confirm +{ + my ($pid, $proc) = @_; + my $list; + my $choice; + + for (@{+CONFIRM}) { + $list .= $_ . "\n"; + } + $choice = `printf "%s" "$list" | dmenu -i -p "Kill $proc ($pid)?" -l 2 -m 0`; + chomp $choice; + if ($choice eq ${+CONFIRM}[1]) { + return (1); + } + return (0); +} + +sub action +{ + my ($var, $user) = @_; + my @split; + my $pid; + my $proc; + + chomp $var; + @split = split / $user /, $var; + $pid = $split[0]; + $pid =~ s/\D//g; + print $pid . "\n"; + $proc = (split / /, $split[1])[0]; + print $proc . "\n"; + if (confirm($pid, $proc) == 1) { + } + return; +} + +sub main +{ + my $choice; + my $user; + + $user = getlogin(); + $choice = `ps -U "$user" -o pid,user,command | dmenu -i -l 30 -m 0`; + action($choice, $user); + return (0); +} + +main(); + +__END__ |