只有一個化合物可以是美麗的,從來沒有任何零件。而且只有一個;
幾個部分將擁有美麗,而不是自己,
但是,只有共同努力,可以給出一個共同的總和。
然而,總體中的美需要詳細的美:
它不能是出於醜陋而建造的;它的定律必須貫穿。
- Plotinus,首先
您是否使用過Sublime Text's或Atom的“ Command Palette”?這是這些編輯可以做的所有事情的列表,這些列表在按鍵的印刷機上打開,並通過輸入幾個字母來找到您正在尋找的操作。觸手可及的原始力量。
Plotinus將該電源帶給您系統上的每個應用程序(即使用GTK+ 3工具包的應用程序)。它通過內省運行的應用程序自動提取所有可用命令,立即適應UI更改並僅顯示相關操作。使用Plotinus不需要對應用程序本身進行任何修改!
只需按Ctrl+Shift+P (可配置),您就可以從事業務 - 很自然,您很快就會想知道沒有它的生活。
要從源構建Plotinus,您需要Git,Cmake,Vala和GTK+ 3開發文件。所有這些都很容易在大多數現代Linux分佈上獲得:
sudo dnf install git cmake vala gtk3-devel
sudo apt-get install git cmake valac libgtk-3-dev
git clone https://github.com/p-e-w/plotinus.git
cd plotinus
mkdir build
cd build
cmake ..
make
sudo make install
由於Linux環境變量周圍的複雜性和笨拙,Plotinus當前未自動啟用。為系統上所有應用程序啟用Plotinus的最簡單方法是添加行
GTK3_MODULES=[libpath]
到/etc/environment , [libpath]是libplotinus.so的完整,絕對的路徑,可以使用命令找到它
whereis -b libplotinus
另外,您可以通過運行單個應用程序來嘗試使用Plotinus
GTK3_MODULES=[libpath] application
從終端。
可以在全球和每個應用程序上配置Plotinus。應用程序設置優先於全球設置。在下面的命令中, [application]可以是
default ,在這種情況下,設置將在全球應用,或/usr/bin/gedit > usr.bin.gedit )。請注意,相關路徑是該過程可執行的路徑,這並不總是與啟動的可執行文件相同。例如,所有GNOME JavaScript應用程序都運行該過程/usr/bin/gjs 。
gsettings set com.worldwidemann.plotinus:/com/worldwidemann/plotinus/[application]/ enabled [true/false]
gsettings set com.worldwidemann.plotinus:/com/worldwidemann/plotinus/[application]/ hotkeys '[keys]'
[keys]必須是gtk_accelerator_parse預期的格式中的一系列字符串,例如["<Primary><Shift>P", "<Primary>P"] 。陣列中的每個快捷方式都打開命令調色板。
gsettings set com.worldwidemann.plotinus:/com/worldwidemann/plotinus/[application]/ dbus-enabled [true/false]
有關詳細信息,請參見以下部分。
Plotinus為想要從自己的軟件中使用其功能的開發人員提供了簡單但完整的D-BUS API。 API由兩種方法組成,在com.worldwidemann.plotinus上的會話總線上暴露於:
GetCommands(window_path) -> (bus_name, command_paths)
獲取GTK+窗口的對象路徑(例如,可以通過meta_window_get_gtk_window_object_path從穆特窗口獲得,並返回引用從該窗口中提取的命令的對象路徑數組,以及已註冊的總線名稱。
這種方法背後的機制與Ubuntu的AppMenu註冊服務商有些相似,但與Wayland更輕巧和兼容。在使用此方法之前,必須啟用窗口註冊。
ShowCommandPalette(commands) -> (bus_name, command_palette_path)
採用一系列命令( (path, label, accelerators) ),並打開顯示這些命令的命令調色板窗口。返回的對象路徑引用在返回的總線名稱上註冊的控制對象,該對像在與窗口的交互時提供了信號。
plotinus d-Bus服務處理這些方法的調用,可以從
plotinus
以下示例演示瞭如何使用Python的D-BUS API。他們要求安裝Pydbus,並且Plotinus d-Bus服務正在運行。
#!/usr/bin/env python
import sys
from pydbus import SessionBus
bus = SessionBus ()
plotinus = bus . get ( "com.worldwidemann.plotinus" )
bus_name , command_paths = plotinus . GetCommands ( sys . argv [ 1 ])
commands = [ bus . get ( bus_name , command_path ) for command_path in command_paths ]
for i , command in enumerate ( commands ):
print ( "[%d] %s -> %s" % ( i , " -> " . join ( command . Path ), command . Label ))
index = raw_input ( "Number of command to execute: " )
if index :
commands [ int ( index )]. Execute ()在運行此示例之前,請使用
gsettings set com.worldwidemann.plotinus:/com/worldwidemann/plotinus/default/ dbus-enabled true
然後,使用啟用Plotinus運行一個應用程序(例如GEDIT)。現在以窗口對象路徑作為參數運行腳本,即
./application_remote_control.py /org/gnome/gedit/window/1
基於此Argos插件,使用Plotinus的命令調色板顯示系統上可用的應用程序列表。
#!/usr/bin/env python
import os , re
from pydbus import SessionBus
from gi . repository import GLib , Gio
applications = {}
for app_info in Gio . AppInfo . get_all ():
categories = app_info . get_categories ()
if categories is None :
continue
# Remove "%U" and "%F" placeholders
command_line = re . sub ( "% \ w" , "" , app_info . get_commandline ()). strip ()
app = ( app_info . get_name (), command_line )
for category in categories . split ( ";" ):
if category not in [ "GNOME" , "GTK" , "" ]:
if category not in applications :
applications [ category ] = []
applications [ category ]. append ( app )
break
commands = []
command_lines = []
for category , apps in sorted ( applications . items ()):
for app in sorted ( apps ):
commands . append (([ category ], app [ 0 ], []))
command_lines . append ( app [ 1 ])
bus = SessionBus ()
plotinus = bus . get ( "com.worldwidemann.plotinus" )
bus_name , command_palette_path = plotinus . ShowCommandPalette ( commands )
command_palette = bus . get ( bus_name , command_palette_path )
loop = GLib . MainLoop ()
def command_executed ( index ):
os . system ( command_lines [ index ])
command_palette . CommandExecuted . connect ( command_executed )
def closed ():
# Wait for CommandExecuted signal
GLib . timeout_add ( 500 , loop . quit )
command_palette . Closed . connect ( closed )
loop . run ()GTK+模塊上的文檔本質上是不存在的。如果沒有Gtkparasite和Gnome-Globalmenu可以學習,那麼將該項目脫離地面將會更加困難。
Cmake模塊是從基本的Pantheon-installer存儲庫中逐字複製的。
Vala仍然是Linux桌面開發中最偉大的事情。
總是歡迎貢獻者。但是,請提出一個問題,描述您打算在打開拉動請求之前要添加的內容,尤其是對於新功能!我對我想要(並且不想)Plotinus的內容有一個清晰的願景,因此討論潛在的添加可能有助於您避免重複和浪費的工作。
通過貢獻,您同意在與項目其餘部分相同的許可下發布更改(請參見下文)。
版權所有©2016-2017 Philipp Emanuel Weidmann([email protected])
根據GNU通用公共許可證的條款發布,版本3