2

Is it possible to launch the calendar application by clicking on the date in the top-right of the screen in system tray, or from any items in its drop down menu?

I'm referring to the default calendar application of Ubuntu (Unity).

For more clarity i mean open calendar by clicking here:

6
  • @JacobVlijm: gnome-calendar is default in Ubuntu 16.04. Feb 27 '17 at 11:35
  • @GunnarHjalmarsson AHA, I totally missed that. Never seen it, sincve I use the thunderbird plugin :) Feb 27 '17 at 11:37
  • AFAIK you can't launch Calendar from the clock menu. But appointments in Calendar will be shown in the clock. Feb 27 '17 at 11:40
  • Ah, I misread the question, indeed from the clock menu is an operation that would need breaking in the code. Is an additional icon in the panel an option? Feb 27 '17 at 11:49
  • While @JacobVlijm may have some idea, it may be worth mentioning that Evolution has the kind of integration you ask for, i.e. you can open it from the clock menu. OTOH, Evolution if kind of 'heavy' and takes a few seconds to launch. Feb 27 '17 at 11:58
0

As mentioned in comments, adding gnome-calendar to the existing Time & Date menu would require breaking into the code. Apart from the fact that that seems to be out of the scope of AU, on the first update you'd need to to the same routine again.

Alternatively

Run the indicator below. It will add an icon to the panel for quick access to the calendar:

enter image description here

The code

#!/usr/bin/env python3
import signal
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk, AppIndicator3
import subprocess

class Indicator():
    def __init__(self):
        self.app = 'test123'
        iconpath = "org.gnome.Calendar"
        self.indicator = AppIndicator3.Indicator.new(
            self.app, iconpath,
            AppIndicator3.IndicatorCategory.OTHER)
        self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)       
        self.indicator.set_menu(self.create_menu())

    def create_menu(self):
        menu = Gtk.Menu()
        open_cal = Gtk.MenuItem('Show Calendar')
        open_cal.connect('activate', self.run_cal)
        menu.append(open_cal)
        # separator
        menu_sep = Gtk.SeparatorMenuItem()
        menu.append(menu_sep)
        # quit
        item_quit = Gtk.MenuItem('Quit')
        item_quit.connect('activate', self.stop)
        menu.append(item_quit)
        menu.show_all()
        return menu

    def run_cal(self, source):
        subprocess.Popen("gnome-calendar")

    def stop(self, source):
        Gtk.main_quit()

Indicator()
signal.signal(signal.SIGINT, signal.SIG_DFL)
Gtk.main()

How to use

  1. Not sure if python3-gi is installed by default, but to make sure:

    sudo apt install python3-gi
    
  2. Copy the script into an empty file, save it as indicator_runcal.py

  3. Test- run it with the command

    python3 /path/to/indicator_runcal.py
    

    A pnale icon should be added as in the image, choose Show Calendar from its menu.

  4. If all works fine, add to Startup Applications: Dash > Startup Applications > Add. Add the command

    /bin/bash -c "sleep 10 && python3 /path/to/indicator_runcal.py"
    

Additionally

You can give it a launcher:

[Desktop Entry]
Exec=python3 /absolute/path/to/indicator_runcal.py
Name=Show Calendar
Type=Application
Icon=org.gnome.Calendar
  1. Copy the code above into an empty file, save it as cal_indicator.desktop
  2. Replace the path in /absolute/path/to/indicator_runcal.py by the real (and full, don't use ~ or $HOME) path to the script.
  3. Move or copy the file to ~/.local/share/applications, log out and back in.

    Now the indicator can be started from Dash:

    enter image description here

2
  • It works. Though it's not exactly what I looking for, it's the nearest solution. Thanks. Feb 27 '17 at 13:27
  • @Graffio31 I totally agree. The nicest would be to include it in the existing menu. Feb 27 '17 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.