Skip to content

Instantly share code, notes, and snippets.

@zed9h
Created July 17, 2009 03:54
Show Gist options
  • Save zed9h/148854 to your computer and use it in GitHub Desktop.
Save zed9h/148854 to your computer and use it in GitHub Desktop.
trayicon monitors x11 idle state to perform activities on the desktop applications
#CHECK { print map { "$_\n"} keys %INC }
END { print map { "$_\n"} keys %INC }
use Gtk2::TrayIcon;
Gtk2->init;
sub evolution_empty_trash
{
system qq{
ltfx -e '
activate_win_partial "Evolution";
type "<alt>F<up><up><up><up><up><enter>"
'
};
}
#Glib::Idle->add(sub { print "I am here!\n" }, 'data');
Glib::Timeout->add(30*60*1000, sub {
use X11::IdleTime;
$idle = GetIdleTime();
evolution_empty_trash if $idle > 3*60*60*1000;
});
my $icon= Gtk2::TrayIcon->new("icon");
use Gtk2::SimpleMenu;
my $menu = Gtk2::SimpleMenu->new(
menu_tree => [
'_`' => {
item_type => '<Branch>',
children => [
_EvolutonEmptyTrash => { callback => \&evolution_empty_trash, },
_Quit => { callback => sub { Gtk2->main_quit; }, },
],
},
],
);
$icon->add($menu->{widget});
$icon->show_all;
Gtk2->main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment