14

I was in the situation that an application I had was not available in the Unity applications lens after I removed a custom .desktop launcher file in my home directory that had overridden the system-wide one.

My problem was that I needed to apply those changes and update in this case the database of installed .desktop files, but other similar scenarios are also imaginable.

So what could I have done (and do the next time) instead of rebooting or logging out and back in to update the Unity configuration and force it to reload and reinitialize all of its stuff?

I am on 15.10, so unity --reset & does not work because it's deprecated.

I then tried unity --replace & instead, but that crashed my desktop and rendered my TTY7 unusable. It first flashed dark and looked like it was restarting Unity and restoring the desktop, but then it did not react to anything any more. Switching to TTY1 and back left me with a black screen plus mouse cursor. After rebooting via TTY1 login and reboot, it worked again and Unity even recognized my application now.

But if I would have been in a situation where a reboot or logout was no option, what would have been my way to go?

  • 1
    you can try setsid unity, it will 'refresh' unity. On one of my installs it does so, the other it results in a log out. Others seem to say it resets back to defaults, does not here in either case. – doug Oct 4 '15 at 1:02
33
+50

Press Alt+F2 type unity and press Enter.

  • 3
    Simple but genial. I have no idea why nobody thought of this earlier. I don't know how much of Unity gets restarted, but it's definitely enough to recognize overridden .desktop files. Thank you! I'll award you the bounty in a few days, waiting for further responses. – Byte Commander Nov 26 '15 at 13:53
  • 1
    Congratulations to your first bounty @padlyuck! :D – Byte Commander Dec 1 '15 at 16:06
  • 9
    I did this in 16.04 and messed up my windows and some apps closed themselves (e.g. browser). – Daniel Jul 28 '16 at 11:41
  • Can you please elaborate on this ? What exactly does it do? – George D Nov 4 '16 at 14:36
  • 1
    Beware - I did this on 14.04 and it shut down X (and all apps) and I had to log in again. – davidA May 10 '17 at 22:50
6
  • Unity is just a Compiz plugin, you can reload it using:

    compiz --replace
    

    Or to let you close terminal

    compiz --replace & disown
    

    To confirm, you can check:

    $ file `which unity`
    /usr/bin/unity: Python script, ASCII text executable
    
    $ more /usr/bin/unity
    
  • Another way, light reload only the plugin (very quick)

    1. Create the compiz_plugin_reloader script

      Source: iXce’s blog: Compiz plugin reloader

      #!/usr/bin/env python
      
      '''Compiz plugin reloader (through compizconfig)
      Copyright (c) 2007 Guillaume Seguin <guillaume@segu.in>
      Licensed under GNU GPLv2'''
      
      import compizconfig
      from sys import argv, exit
      from time import sleep
      
      if __name__ == "__main__":
          if len (argv) < 2:
              print "Usage : %s plugin1 [plugin2 ... pluginN]" % argv[0]
              exit (2)
          plugins = argv[1:]
          context = compizconfig.Context (basic_metadata = True)
          print "Unloading " + " ".join (plugins)
          for plugin in plugins:
              if plugin not in context.Plugins:
                  print "Warning : %s plugin not found" % plugin
                  plugins.remove (plugin)
                  continue
              context.Plugins[plugin].Enabled = False
          if len (plugins) == 0:
              print "Error : no plugin found"
              exit (1)
          context.Write ()
          print "Waiting for settings update"
          sleep (2)
          print "Loading " + " ".join (plugins)
          for plugin in plugins:
              context.Plugins[plugin].Enabled = True
          context.Write ()
      
    2. Fix permissions

      chmod +x compiz_plugin_reloader
      
    3. Run as:

      ./compiz_plugin_reloader unityshell
      

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.