· 7 years ago · Oct 26, 2018, 08:14 AM
1use strict;
2use warnings;
3use Switch;
4use List::MoreUtils qw(first_index);
5
6$SIG{INT}=sub{ die "goodnight !\n $!"; };
7my $underline='#ffffff';
8my $default_background='#51002f';
9my $default_workspace_background='#727272';
10my $default_workspace_foreground='#ffffff';
11my $default_foreground='#ffffff';
12my $focussed_background='#000000';
13my $focussed_foreground='#ffffff';
14my $occupied_background='#3a3a3a';
15my $occupied_foreground='#ffffff';
16my @desktops=qx/ bspc query -D /;
17my @lemonbar_array=();
18my $lemonbar_string="%{B$default_background}%{F$default_foreground}%{+u}  0x00400004 %{-u}%{B-}%{F-}";
19my $date_string="%{c}%{B$focussed_background}%{F$default_foreground}%{+u} %date %{-u}%{B-}%{F-}";
20
21my $add_this="%{+u}%{B$default_background}%{F$default_foreground} %{A:firefox:} web %{A} %{B-}%{F-} %{B$default_background}%{F$default_foreground} %{A:evince:} pdf %{A} %{B-}%{F-} %{B$default_background}%{F$default_foreground} %{A:libreoffice:} doc %{A} %{B-}%{F-} %{B$default_background}%{F$default_foreground} %{A:firefox youtube.com:} youtube %{A} %{B-}%{F-} %{B$default_background}%{F$default_foreground} %{A:firefox netflix.com:} netflix %{A} %{B-}%{F-} %{B$default_background}%{F$default_foreground} %{A:firefox gmail.com:} gmail %{A} %{B-}%{F-} %{B$default_background}%{F$default_foreground} %{A:firefox protonmail.com:} protonmail %{A} %{B-}%{F-} %{B$default_background}%{F$default_foreground} %{A:nautilus:} files %{A} %{B-}%{F-} %{B$default_background}%{F$default_foreground} %{A:urxvt:} terminal %{A} %{B-}%{F-}%{-u}";
22
23for(my $i=0;$i<=9;$i++){
24 push(@lemonbar_array,$lemonbar_string);
25}
26
27my $current_monitor='';
28
29while() {
30 my $date=gmtime();
31 $date_string=~s/%date/$date/;
32 $current_monitor=qx/bspc query -D -d/;
33 my $index_current_monitor=first_index { $_ eq $current_monitor } @desktops;
34 my $index_print=$index_current_monitor+1;
35 $lemonbar_array[$index_current_monitor]=~s/(?<=B)#.{6}/$focussed_background/;
36 $lemonbar_array[$index_current_monitor]=~s/(?<=F)#.{6}/$focussed_foreground/;
37 $lemonbar_array[$index_current_monitor]=~s/0x00.{6}/$index_print/;
38 for(my $i=0;$i<10;$i++){
39 if($desktops[$i] ne $current_monitor){
40 my $i1=$i+1;
41 $lemonbar_array[$i]=~s/0x00.{6}/$i1/;
42 if(scalar(my @n=qx/bspc query -N -d $desktops[$i]/) gt 0){
43 $lemonbar_array[$i]=~s/(?<=B)#\w{6}/$occupied_background/;
44 $lemonbar_array[$i]=~s/(?<=F)#\w{6}/$occupied_foreground/;
45 }
46 else{
47 $lemonbar_array[$i]=~s/(?<=B)#\w{6}/$default_workspace_background/;
48 $lemonbar_array[$i]=~s/(?<=F)#\w{6}/$default_workspace_foreground/;
49
50
51
52 }
53 }
54 }
55
56 print "%{l}@lemonbar_array $date_string %{r}$add_this\n";
57}