Gnome plugin with Python

You can create Gnome 3.x plugins straight from Python. Of course, you should know Python programming. It’s not that hard to do. Great! how do you create a plugin?

Do you use/like Gnome desktop? It’s the default desktop on many Linux distros like Ubuntu, Debian, OpenSuse and others.

It’s this one:

The setup

It takes some setup before you can run Python script on the gnome desktop. I’ve tested this on then newest gnome desktop, it may not work for classic gnome desktop (mate).

Setup the argos plugin and enable it using gnome tweak tool.

Click extensions and enable argos. If you don’t have tweak tool, run this command

sudo apt install gnome-tweak-tool
sudo apt install gnome-tweak-tool
sudo apt install gnome-tweak-tool

Enter fullscreen mode Exit fullscreen mode

Create the gnome plugin

Then open a terminal (Ctrl+Alt+T) and type this

cd ~/.config/argos
nano launcher.py
cd ~/.config/argos
nano launcher.py
cd ~/.config/argos nano launcher.py

Enter fullscreen mode Exit fullscreen mode

or any other editor.
Paste the Python code below.

#!/usr/bin/env python
import re
from gi.repository import Gio
print("Python | iconName=starred")
print("---")
print("Gedit | iconName=gedit bash=gedit terminal=false")
print("Nautilus | iconName=system-file-manager bash=nautilus terminal=false")
print("---")
#!/usr/bin/env python

import re
from gi.repository import Gio

print("Python | iconName=starred") 
print("---")
print("Gedit | iconName=gedit bash=gedit terminal=false")
print("Nautilus | iconName=system-file-manager bash=nautilus terminal=false")
print("---")
#!/usr/bin/env python import re from gi.repository import Gio print("Python | iconName=starred") print("---") print("Gedit | iconName=gedit bash=gedit terminal=false") print("Nautilus | iconName=system-file-manager bash=nautilus terminal=false") print("---")

Enter fullscreen mode Exit fullscreen mode

Save and close. Then type

chmod +x launcher.py
chmod +x launcher.py
chmod +x launcher.py

Enter fullscreen mode Exit fullscreen mode

You should now see the Python script output in your tool bar. The plugin argos will scan the directory ~/.config/argos constantly for changes.
Any file you place in there is a plugin.

Related links

原文链接:Gnome plugin with Python

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
To the path of timber, iron and steel will never regret bright spray of molten steel was abandoned.
为了走上成材的道路,钢铁决不惋惜璀璨的钢花被遗弃
评论 抢沙发

请登录后发表评论

    暂无评论内容