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?

Byte Commander
  • 110,243

2 Answers2

33

Press Alt+F2 type unity and press Enter.

hg8
  • 13,582
padlyuck
  • 496
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
      
user.dz
  • 49,176