Ubuntu – How to make indicator-sysmonitor as a default indicator on the login screen

indicatorlightdmunity

The Ubuntu 14.04 currently have at the top right corner these indicators shutdown,lock button, calender time details, battery details, Input format (English) as the default indicators. Is it possible to make indicator-sysmonitor as one of those default indicators.

Now what happens is only when we logged into a computer, indicator-sysmonitor will be shown and when you log out or lock our computer indicator-sysmonitor will automatically exit from panel. I know from experience in locked computers indicator-sysmonitor works in the background but will not show in the panel. I have some stats (includes cpu,mem and some custom) which i want to see when i lock my computer.

can it be done?

P.S. I have asked this question in the main software site and the author recommended this site.


I've looked at this Question and its answers and it looks promising – but I don't know how to adapt the answers for indicator-sysmonitor.

Best Answer

Greeter/Login Screen

I end up looking how the nm-applet works. I tracked it down, as it seems hard coded in unity-greeter.

This modification make it appear in the greeting screen after boot or logoff (but not in the lock screen).

  1. Download source and build dependencies

    sudo apt-get build-dep unity-greeter
    apt-get source unity-greeter
    
  2. Add spawn function for indicator-sysmonitor

    cd unity-greeter-*/
    vim src/unity-greeter.vala +590
    

    There you find Process.spawn_command_line_async ("nm-applet"); in original code which spawn the nm-applet for the greeter screen. Make a copy of it with the full try..catch wrap and modify it to spawn indicator-sysmonitor too.

        /* Make nm-applet hide items the user does not have permissions to interact with */
        Environment.set_variable ("NM_APPLET_HIDE_POLICY_ITEMS", "1", true);
    
        try
        {
            Process.spawn_command_line_async ("nm-applet");
        }
        catch (Error e)
        {
            warning ("Error starting nm-applet: %s", e.message);
        }
    
        /* I added these for sysmonitor, from here */
        try
        {
            Process.spawn_command_line_async ("indicator-sysmonitor");
        }
        catch (Error e)
        {
            warning ("Error starting indicator-sysmonitor: %s", e.message);
        }
        /* to here */
    
    }
    
  3. Build

    ./autogen.sh
    ./configure --prefix=/usr
    make -j2
    
  4. Install

    sudo cp src/unity-greeter /usr/local/sbin/unity-greeter
    
  5. Reboot

    indicator-sysmonitor on unity-greeter (Ubuntu greeting screen)


Lock Screen

Anyway, this will show all application indicators (notice nm-applet in the screenshot), this may be a security & privacy drawback. It is possible to pre-define an indicator list for lockscreen mode only, I just don't have time to do so and test it.

  1. Download source and build dependencies

    sudo apt-get build-dep unity
    apt-get source unity
    
  2. Modify unity-panel-service to load application indicators even in lockscreen-mode.

    cd unity-7*/
    vim services/panel-service.c +893
    

    if (!lockscreen_mode) below prevent loading indicators in lock screen mode.

    static void
    initial_load_default_or_custom_indicators (PanelService *self, GList *indicators)
    {
      GList *l;
    
      suppress_signals = TRUE;
    
      if (!indicators)
        {
          /* comment these lines
            if (!lockscreen_mode)
            {
              load_indicators (self);
            }
          */
          // add this line
          load_indicators (self);
    
          load_indicators_from_indicator_files (self);
          sort_indicators (self);
        }
    ...
    
  3. Build

    mkdir build
    cd build/
    cmake ../
    make
    
  4. Install

    sudo mv /usr/lib/unity/unity-panel-service /usr/lib/unity/unity-panel-service.orig
    sudo cp services/unity-panel-service /usr/lib/unity/unity-panel-service
    

    Try it: CtrlAltL

    indicator-sysmonitor on lightdm lock screen