Addressing the core issue
So far the cause of your issue with Super+number keys remains unknown, but I strongly believe that you would need to check whether the Super key is enabled under Unity Plugin in Compiz Config Settings Manager. ( obtainable via sudo apt-get install compizconfig-settings-manager
command).
Command-line approach would be via this command:
dconf reset /org/compiz/profiles/unity/plugins/unityshell/show-launcher
Addressing the title question
However, to address the title question that you have, namely whether there is a command-line tool for open a program from Unity launcher . . . well, there wasn't a tool like that until now. The script given below performs exactly that function.
Usage
As given by -h
option:
$ ./open_launcher_item.py -h
usage: open_launcher_item.py [-h] -i ITEM
optional arguments:
-h, --help show this help message and exit
-i ITEM, --item ITEM position of app on the launcher
So if you wanted to launch first app on the launcher, do
./open_launcher_item.py -i 0
If you want second item,
./open_launcher_item.py -i 1
To make the script work, store it in ~/bin
folder. If you don't have bin
folder in your /home/USER
folder, then create one. Ensure the script is executable via chmod +x ~/bin/open_launcher_item.py
command, or by right-clicking on the file in graphical file manager, and checking "Allow executing as program" under Permissions tab.
To make it work for keyboard shortcut, you will have to create like 9 shortcuts, and for each one of them set appropriate command , with -i 0
, -i 1
, and so forth until -i 9
. Please note, that you will need to use full path to the script, i.e. /home/USER/bin/open_launcher_item.py -i 1
Script Source
Also available on GitHub
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Serg Kolo , contact: 1047481448@qq.com
# Date: January 15th, 2017
# Purpose: opens applications on Unity launcher according to position
# Tested on: Ubuntu 16.04 LTS
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gio,Gtk
import sys,argparse
class ApplicationOpener(Gtk.Application):
def __init__(self):
Gtk.Application.__init__(self,flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE)
self.args = None
self.schema = 'com.canonical.Unity.Launcher'
self.key = 'favorites'
def gsettings_get(self, schema, path, key):
"""Get value of gsettings schema"""
if path is None:
gsettings = Gio.Settings.new(schema)
else:
gsettings = Gio.Settings.new_with_path(schema, path)
return gsettings.get_value(key)
def get_launchers(self):
return [ i.replace('application://',"")
for i in self.gsettings_get(self.schema,None,self.key)
if i.startswith('application://')
]
def do_activate(self):
position = self.args.item
launchers = self.get_launchers()
if position > len(launchers):
position = -1
try:
Gio.DesktopAppInfo.new(launchers[position]).launch_uris(None)
except Exception as e:
subprocess.call(['zenity','--error','OOPS! SOMETHING WENT WRONG:\n' + str(e)])
return 0
def do_command_line(self, args):
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--item',
type=int,required=True,
help='position of app on the launcher')
self.args = parser.parse_args(args.get_arguments()[1:])
self.do_activate()
return 0
def main():
app = ApplicationOpener()
exit_status = app.run(sys.argv)
sys.exit(exit_status)
if __name__ == '__main__':
main()