From d1fcd2b8a47be1a4bbed8afc34b8d84106b4e383 Mon Sep 17 00:00:00 2001 From: Sergei Fedosov Date: Wed, 24 Feb 2021 17:50:35 +0300 Subject: [PATCH] i3status-anyevent: Add left|right click cmd for clock plugin --- i3status-anyevent | 16 ++++++++++++++-- i3status-anyevent.json | 10 +++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/i3status-anyevent b/i3status-anyevent index 4f12a27..4c26d51 100644 --- a/i3status-anyevent +++ b/i3status-anyevent @@ -233,7 +233,7 @@ sub add_events () { } if ($CONF->{clock}->{enabled}) { - push @{$OUTPUT}, { color => $CONF->{clock}->{color}, full_text => "$wallclock", markup => 'pango'}; + push @{$OUTPUT}, { name => 'wallclock', color => $CONF->{clock}->{color}, full_text => "$wallclock", markup => 'pango'}; } $output_string = eval { encode_json $OUTPUT }; @@ -274,7 +274,7 @@ sub add_events () { if (defined $j) { # left button click, without shift, ctrl, alt, etc - if (($j->{button} == 1) && ($#{$j->{modifiers}} < 0)){ + if (($j->{button} == 1) && ($#{$j->{modifiers}} < 0)) { foreach (@{$CONF->{apps}}) { unless (defined $_->{name}) { next; @@ -290,6 +290,18 @@ sub add_events () { } } } + + if (($j->{name} eq 'wallclock') && ($CONF->{clock}->{enabled})) { + if ($CONF->{clock}->{left_click}->{enabled}) { + if (($j->{button} == 1) && ($#{$j->{modifiers}} < 0)) { + spawn ($CONF->{clock}->{left_click}->{cmd}); + } + } elsif ($CONF->{clock}->{right_click}->{enabled}) { + if (($j->{button} == 2) && ($#{$j->{modifiers}} < 0)) { + spawn ($CONF->{clock}->{right_click}->{cmd}); + } + } + } } } } diff --git a/i3status-anyevent.json b/i3status-anyevent.json index cd36010..846966d 100644 --- a/i3status-anyevent.json +++ b/i3status-anyevent.json @@ -14,7 +14,15 @@ "clock": { "enabled" : 1, # html (actually, pango) color notation - "color" : "#000000" + "color" : "#000000", + "left_click" : { + "enabled" : 1, + "cmd" : "orage" + }, + "right_click" : { + "enabled" : 0, + "cmd" : "true" + } }, # Battery