diff options
author | Yigit Sever | 2020-11-18 16:22:41 +0300 |
---|---|---|
committer | Yigit Sever | 2020-11-18 16:22:41 +0300 |
commit | 5864b0c43781d319d797a5277e1316e5acd690c1 (patch) | |
tree | 6c1b6727b71f631e22465dedbc6e2357792b2087 | |
parent | 4b136cecbfc63f96d1d203eae513d61706edf72d (diff) | |
download | dotfiles-5864b0c43781d319d797a5277e1316e5acd690c1.tar.gz dotfiles-5864b0c43781d319d797a5277e1316e5acd690c1.tar.bz2 dotfiles-5864b0c43781d319d797a5277e1316e5acd690c1.zip |
tracking polybar task stop script
-rwxr-xr-x | .config/polybar/stop | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/.config/polybar/stop b/.config/polybar/stop new file mode 100755 index 0000000..58f8741 --- /dev/null +++ b/.config/polybar/stop | |||
@@ -0,0 +1,47 @@ | |||
1 | #!/usr/bin/env perl | ||
2 | # shows active taskwarrior task on polybar | ||
3 | #Copyright © 2019 yigit | ||
4 | |||
5 | #This program is free software: you can redistribute it and/or modify | ||
6 | #it under the terms of the GNU General Public License as published by | ||
7 | #the Free Software Foundation, either version 3 of the License, or | ||
8 | #(at your option) any later version. | ||
9 | |||
10 | #This program is distributed in the hope that it will be useful, | ||
11 | #but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | #GNU General Public License for more details. | ||
14 | |||
15 | #You should have received a copy of the GNU General Public License | ||
16 | #along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | use strict; | ||
19 | use warnings; | ||
20 | use IO::CaptureOutput qw/capture_exec/; | ||
21 | |||
22 | my ($stdout, $stderr, $success, $exit_code) = capture_exec("task active"); | ||
23 | |||
24 | # print("out: $stdout\nerr: $stderr\nexit_code: $exit_code\n"); | ||
25 | |||
26 | if ($stderr =~ /No matches\./) { | ||
27 | exit; | ||
28 | } | ||
29 | |||
30 | my $active_task_maybe = $stdout; | ||
31 | |||
32 | $active_task_maybe =~ s/^\s+|\s+$//g; | ||
33 | |||
34 | my @lines = split /\n/, $active_task_maybe; | ||
35 | |||
36 | my $task = $lines[2]; | ||
37 | $task =~ s/^\s+|\s+$//g; # left and right trim | ||
38 | $task =~ s/\s+/ /g; # reduce multiple whitespace into one | ||
39 | |||
40 | if ($task =~ m/^(\d+)(.*)$/g) { | ||
41 | # print ">>$1<< | $2<<"; | ||
42 | my ($stdout, $stderr, $success, $exit_code) = capture_exec("task stop $1"); | ||
43 | if ($stdout =~ m/'(.*)'/) { | ||
44 | exec(qq(dunstify --appname="task" --icon="kt-pause" "stopping" "$1")); | ||
45 | } | ||
46 | } | ||
47 | |||