diff options
Diffstat (limited to '.config/polybar/scripts/focus')
-rwxr-xr-x | .config/polybar/scripts/focus | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/.config/polybar/scripts/focus b/.config/polybar/scripts/focus index 49d46d2..87ee19b 100755 --- a/.config/polybar/scripts/focus +++ b/.config/polybar/scripts/focus | |||
@@ -17,14 +17,22 @@ | |||
17 | 17 | ||
18 | use strict; | 18 | use strict; |
19 | use warnings; | 19 | use warnings; |
20 | use IO::CaptureOutput qw/capture_exec/; | 20 | use Capture::Tiny ':all'; |
21 | 21 | ||
22 | my ($stdout, $stderr, $success, $exit_code) = capture_exec("task custom_focus"); | 22 | my ($stdout, $stderr, $exit_code) = capture { |
23 | system("task custom_focus"); | ||
24 | }; | ||
23 | 25 | ||
24 | if ($stderr =~ /No matches\./) { | 26 | if ($stderr =~ /No matches\./) { |
25 | system 'echo "${SEMESTER_THEME}"'; | 27 | system 'echo "${SEMESTER_THEME}"'; |
26 | exit; | 28 | exit; |
27 | } | 29 | } |
30 | |||
31 | if ($stderr =~ /database is locked/) { | ||
32 | system 'echo "${SEMESTER_THEME}"'; | ||
33 | exit; | ||
34 | } | ||
35 | |||
28 | my $active_task_maybe = $stdout; | 36 | my $active_task_maybe = $stdout; |
29 | 37 | ||
30 | $active_task_maybe =~ s/^\s+|\s+$//g; | 38 | $active_task_maybe =~ s/^\s+|\s+$//g; |
@@ -32,8 +40,9 @@ $active_task_maybe =~ s/^\s+|\s+$//g; | |||
32 | my @lines = split /\n/, $active_task_maybe; | 40 | my @lines = split /\n/, $active_task_maybe; |
33 | 41 | ||
34 | my $task = $lines[2]; | 42 | my $task = $lines[2]; |
35 | $task =~ s/^\s+|\s+$//g; # left and right trim | 43 | $task =~ s/^\s+|\s+$//g; # left and right trim |
36 | $task =~ s/\s+/ /g; # reduce multiple whitespace into one | 44 | $task =~ s/\s+/ /g; # reduce multiple whitespace into one |
45 | $task =~ s/&/&/g; # escape ampersands | ||
37 | 46 | ||
38 | my $context = `task context | grep yes | cut -d' ' -f1`; | 47 | my $context = `task context | grep yes | cut -d' ' -f1`; |
39 | 48 | ||