summaryrefslogtreecommitdiffstats
path: root/.config/polybar/scripts/focus
diff options
context:
space:
mode:
authorYigit Sever2021-10-27 11:05:01 +0300
committerYigit Sever2021-10-27 11:05:01 +0300
commit67f5cb9386454d9a3fa2517540de03c2ed6f08f3 (patch)
treeda9df8c1fee214c76a65c1a648e5f83fb0611d8e /.config/polybar/scripts/focus
parent5ee15326de8e22f86eabd2ec0d0087ef12724f45 (diff)
downloaddotfiles-67f5cb9386454d9a3fa2517540de03c2ed6f08f3.tar.gz
dotfiles-67f5cb9386454d9a3fa2517540de03c2ed6f08f3.tar.bz2
dotfiles-67f5cb9386454d9a3fa2517540de03c2ed6f08f3.zip
polybar: clean up the scripts
Diffstat (limited to '.config/polybar/scripts/focus')
-rwxr-xr-x.config/polybar/scripts/focus46
1 files changed, 46 insertions, 0 deletions
diff --git a/.config/polybar/scripts/focus b/.config/polybar/scripts/focus
new file mode 100755
index 0000000..49d46d2
--- /dev/null
+++ b/.config/polybar/scripts/focus
@@ -0,0 +1,46 @@
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
18use strict;
19use warnings;
20use IO::CaptureOutput qw/capture_exec/;
21
22my ($stdout, $stderr, $success, $exit_code) = capture_exec("task custom_focus");
23
24if ($stderr =~ /No matches\./) {
25 system 'echo "${SEMESTER_THEME}"';
26 exit;
27}
28my $active_task_maybe = $stdout;
29
30$active_task_maybe =~ s/^\s+|\s+$//g;
31
32my @lines = split /\n/, $active_task_maybe;
33
34my $task = $lines[2];
35$task =~ s/^\s+|\s+$//g; # left and right trim
36$task =~ s/\s+/ /g; # reduce multiple whitespace into one
37
38my $context = `task context | grep yes | cut -d' ' -f1`;
39
40if ($task =~ m/^(.*)?\s(\d+\w+)$/g) {
41 if ($context) {
42 print "$1 | $2 @ $context";
43 } else {
44 print "$1 | $2";
45 }
46}