Ubuntu 17.10 推出 [論壇 - Ubuntu 與 GNOME]
正在瀏覽:
1 名遊客
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引]
================================================================================ # 關於「Gnome Shell」的「Looking Glass」操作使用 ================================================================================ 我在複習之前寫的「文章」,一些基礎的概念,大部分都適用目前的版本,只有一些小細節,有差異。 上面的連結,以前有紀錄在「如何撰寫Gnome Shell Extension」這篇討論串。 而以下則是「溫故知新」後的紀錄。 ================================================================================ ## 測試環境 執行
顯示
================================================================================ ## 文件 * https://wiki.gnome.org/Projects/GnomeShell/LookingGlass * https://wiki.gnome.org/Projects/GnomeShell/CheatSheet#Developer_tools ================================================================================ ## 基本技巧 ### 呼叫出「Looking Glass」 * 鍵盤按下「<Alt> + F2」,呼叫出「Command輸入視窗」。 * 然後輸入「lg」,鍵盤按下「Enter」,執行呼叫出「Looking Glass」。 ### 重新啟動「gnome-shell」 * 鍵盤按下「<Alt> + F2」,呼叫出「Command輸入視窗」。 * 然後輸入「r」,不登出,重新啟動「gnome-shell」。(不過這個在「Waylan Session」無法重新啟動) ================================================================================ ## 測試「Main.notify()」和「Main.notifyError()」這兩個「function(method)」。 1. 呼叫出「Looking Glass」,然後在「Evaluator」這一分頁。 輸入「Main.notify("This is notify message")」 就會發現,會跳出訊息視窗。 2. 呼叫出「Looking Glass」,然後在「Evaluator」這一分頁, 輸入「Main.notifyError("This is notifyError message")」。 就會發現,會跳出訊息視窗。 然後在訊息視窗還沒消失,在畫面上方的「TopBar」中間有一個日期,按下之後,會下拉一個選單, 下拉選單右方是日曆,左方則會有一筆剛剛的訊息。 然後在「/var/log/syslog」這個檔案,也可以找到紀錄。 執行下面指令,
就可以看到其中有一行如下
3. 呼叫出「Looking Glass」,然後在「Evaluator」這一分頁, 輸入「Main」,就會看到「r(3) = [object GjsModule ui.main]」, 可以用滑鼠點「[object GjsModule ui.main]」,就會出現另一個對話框。 可以了解到「Main」這個物件,有哪些「Property」和「Methond」。 您可以看到其中有兩行如下
================================================================================ ## 測試「global.log()」和「global.logError()」這兩個「function(method)」。 1. 呼叫出一個您慣用的「Terminal」起來,然後執行下面的指令。
2. 呼叫出「Looking Glass」,然後在「Evaluator」這一分頁, 輸入「global.log("This is global.log message")」, 就可以看到下面這一行,出現在剛剛「Terminal」的最後一行。
3. 呼叫出「Looking Glass」,然後在「Evaluator」這一分頁, 輸入「global.logError("This is global.logError message")」, 就可以看到下面這一行,出現在剛剛「Terminal」的最後一行。
3. 呼叫出「Looking Glass」,然後在「Evaluator」這一分頁, 輸入「global」,就會看到「r(6) = [object instance proxy GIName:Shell.Global jsobj@0x7f3308263820 native@0xb684d0]」, 可以用滑鼠點「[object instance proxy GIName:Shell.Global jsobj@0x7f3308263820 native@0xb684d0]」,就會出現另一個對話框。 可以了解到「global」這個物件,有哪些「Property」和「Methond」。 您可以看到其中有兩行如下
================================================================================ ## this 1. 呼叫出「Looking Glass」,然後在「Evaluator」這一分頁, 輸入「this」,就會看到「r(8) = [object LookingGlass]」, 可以用滑鼠點「[object LookingGlass]」,就會出現另一個對話框。 可以了解到「this」這個物件,有哪些「Property」和「Methond」。 您可以看到其中有一行如下
然後按下鍵盤「Esc」鍵,關閉剛剛的「inpecting」對話框。 然後在「Evaluator」這一分頁, 輸入「this.toggle()」或是「this.close()」,就會關閉「Looking Glass」。 當然也可以鍵盤「Esc」鍵,關閉「Looking Glass」。 ================================================================================ ## window 1. 呼叫出「Looking Glass」,然後在「Evaluator」這一分頁, 輸入「window」,就會看到「r(7) = [object GjsGlobal]」, 可以用滑鼠點「[object GjsGlobal]」,就會出現另一個對話框。 可以了解到「window」這個物件,有哪些「Property」和「Methond」。 您可以看到
表示「window」這個物件底下,可以參考到剛剛的「global」物件。 然後按下鍵盤「Esc」鍵,關閉剛剛的「inpecting」對話框。 然後在「Evaluator」這一分頁, 先輸入「window.」,然後連續按兩下鍵盤「Tab」鍵,也會出現很多「window」這個物件底下的「member」。 顯示如下的資訊
可以看到「window」也有「log」和「logError」。 上面這一段,也可以在「Evaluator」這一分頁輸入下面這一行指令,
就可以在「/var/log/syslog」找到如下的訊息
我是參考「gnome-shell」的原始碼, 在「gnome-shell/js/ui/lookingGlass.js」這個路徑,可以找到下面這一行,然後再修改成上面的指令。
================================================================================ ## Expression 1. 呼叫出「Looking Glass」,然後在「Evaluator」這一分頁, 輸入「a = 1」,按下鍵盤「Enter」鍵, 會顯示
接著輸入「a」,按下鍵盤「Enter」鍵, 會顯示
接著輸入「window.a」,按下鍵盤「Enter」鍵, 會顯示
接著輸入「window」,就會看到「r(13) = [object GjsGlobal]」, 可以用滑鼠點「[object GjsGlobal]」,就會出現另一個對話框。
可以看到其中有一行「a: 1」。 接著輸入「window.」,然後連續按兩下鍵盤「Tab」鍵, 就會看到如下的訊息
也會出現「a」。 接著輸入「delete a」,按下鍵盤「Enter」鍵, 會顯示
接著輸入「a」,按下鍵盤「Enter」鍵, 會顯示
接著輸入「a」,按下鍵盤「Enter」鍵,
然後在「window」的「inspect」視窗,也看不到「a: 1」。 而輸入「window.」,連續按兩下鍵盤「Tab」鍵,也看不到「a」的蹤跡了。 接著輸入「say = function() {return 9}」,然後按下「Enter」鍵, 會顯示
接著輸入「say」,然後按下「Enter」鍵, 會顯示
接著輸入「say()」,然後按下「Enter」鍵, 會顯示
接著輸入「say = function() {log('say hello')}」,然後按下「Enter」鍵, 會顯示
接著輸入「say()」,然後按下「Enter」鍵, 會顯示
也可以在「/var/log/syslog」找到下面這一行紀錄。
同理,在「window」也可以找到「say」的蹤跡, 輸入「window.say」,然後按下「Enter」鍵, 會顯示
================================================================================ 執行
會下載下面三個檔案 * gnome-shell_3.26.1-0ubuntu5.debian.tar.xz * gnome-shell_3.26.1-0ubuntu5.dsc * gnome-shell_3.26.1.orig.tar.xz 並且解開到「gnome-shell-3.26.1」這個資料夾。 執行下面指令,找尋跟「Inspecting」相關的檔案。
顯示 gnome-shell-3.26.1/js/ui/lookingGlass.js:395: let label = new St.Label({ text: 'Inspecting: %s: %s'.format(typeof(obj), 執行下面指令,找尋跟「js function」相關的檔案。
顯示 gnome-shell-3.26.1/js/ui/lookingGlass.js:260: return '<js function>'; 執行
顯示 gnome-shell-3.26.1/js/ui/main.js:113: global.logError = window.log; gnome-shell-3.26.1/js/ui/main.js:114: global.log = window.log; gnome-shell-3.26.1/NEWS:2694:* Don't use global.log() [Jasper; #675790] 執行
顯示 gnome-shell-3.26.1/js/ui/main.js:113: global.logError = window.log; 執行下面指令,找尋跟「windowlo.global」相關的檔案。
顯示 gnome-shell-3.26.1/js/extensionPrefs/main.js:380: window.global = { gnome-shell-3.26.1/js/ui/environment.js:84: window.global = Shell.Global.get(); gnome-shell-3.26.1/src/shell-global.c:545: * it's available as window.global inside JS.) 執行
執行下面指令,找尋跟「function notify」相關的檔案。 顯示
執行
顯示
執行
顯示
執行
顯示 gnome-shell-3.26.1/js/extensionPrefs/main.js:385: logError: function(s) { 執行
顯示 gnome-shell-3.26.1/js/ui/messageTray.js:802: notify: function(notification) { gnome-shell-3.26.1/js/ui/status/network.js:1739: _notify: function(iconName, title, text, urgency) { gnome-shell-3.26.1/js/ui/components/telepathyClient.js:591: notify: function() { gnome-shell-3.26.1/src/shell-perf-log.c:589: * @notify: function to call when @user_data is no longer needed gnome-shell-3.26.1/src/shell-global.c:1679: * @notify: function to call to free @user_data 執行
沒有顯示 ================================================================================ # Picker 按鈕 在「Looking Glass」左上方有兩個按鈕,左方數來第一個按鈕,按下後, 可以在畫面點選某物件,就會出現在「Evaluator」, 然後就可以「inpect」該物件。 ================================================================================ 接下來在另一篇介紹「import.searchPath」。 ================================================================================ [回到索引]
2017/10/30 21:23
|
||||||||||
![]() |
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引]
================================================================================ # 關於「imports.searchPath」 ================================================================================ ## 文件 * https://wiki.gnome.org/Projects/Gjs/StyleGuide#Imports * https://wiki.gnome.org/Projects/GnomeShell/Gjs_StyleGuide#Imports ================================================================================ ## gjs 在「Terminal」下, 產生一個檔「test.js」,內容如下 #!/usr/bin/env gjs print(imports.searchPath.length); for (let path of imports.searchPath) { print(path); } 然後執行
顯示
或是也可以先執行「chmod u+x test.js」,然後再執行「./test.js」也會出現上面的結果。 ================================================================================ ## Looking Glass 在「Looking Glass / Evaluator」, 執行下面指令 for (let path of imports.searchPath) { log(path); } 執行
就可以在「/var/log/syslog」找到如下的訊息
因為呼叫log,換行會被改寫成「#012」, 可以測試「log("-\n-")」, 在「/var/log/syslog」看到「Oct 30 09:54:49 my-host gnome-shell[865]: -#012-」 所以改寫一下程式 var list = ''; for (let path of imports.searchPath) { list += path; list += "\n"; } imports.gi.GLib.file_set_contents("/tmp/lg-search-path.log", list); 執行
顯示
執行
關於「imports.searchPath」應該是「Array」, 參考「MDN / javscript / typeof (中文)」裡面的說明, 在「Looking Glass / Evaluator」, 執行
會得到
執行
會得到
執行
會得到
所以「imports.searchPath」的用法,就可以參考「MDN / Javascript / Array(中文)」。 實作的原始碼,應該是要從「gjs/gjs/importer.cpp」探索起。 ================================================================================ ## 範例一 在「Terminal」, 執行下面指令,產生「/tmp/js/lg」這個資料夾。
執行下面指令,產生「/tmp/js/lg/agent.js」這個檔案。 cat > /tmp/js/lg/agent.js <<EOF const Main = imports.ui.main; function hi() { Main.notify("Hello!"); } EOF 執行下面指令,觀看「/tmp/js/lg/agent.js」這個檔案的內容
顯示 const Main = imports.ui.main; function hi() { Main.notify("Hello!"); } ================================================================================ 在「Looking Glass / Evaluator」, 執行下面指令
顯示
執行下面指令
在「Evaluator Pane」會顯示
在畫面上方中間,則會跳出一個提示訊息對話框,顯示「Hello」。 然後可以先輸入「imports.agent.」,再連續按下兩次「Tab」鍵,就會看到如下的資訊
上面資訊,可以執行下面指令獲得。
接著繼續在「Looking Glass / Evaluator」執行下面指令
顯示
執行下面指令
顯示
執行下面指令
顯示
================================================================================ ## 範例二 在「Terminal」, 執行下面指令,產生「/tmp/js/gjs/lib」這個資料夾。
執行下面指令,產生「/tmp/js/gjs/lib/agent.js」這個檔案。 cat > /tmp/js/gjs/lib/agent.js <<EOF const Notify = imports.gi.Notify; function hi() { Notify.init('Hello world'); let notify = new Notify.Notification({ summary: 'Hello world!', body: 'This is an example of notifications.', 'icon-name': 'dialog-information' }); notify.show(); } EOF 執行下面指令,觀看「/tmp/js/gjs/lib/agent.js」這個檔案的內容
顯示 const Notify = imports.gi.Notify; function hi() { Notify.init('Hello world'); let notify = new Notify.Notification({ summary: 'Hello world!', body: 'This is an example of notifications.', 'icon-name': 'dialog-information' }); notify.show(); } 上面程式碼,是參考自 * https://wiki.archlinux.org/index.php/Desktop_notifications#Usage_in_programming ================================================================================ 接下來,要來測試載入剛剛產生的模組「/tmp/js/gjs/lib/agent.js」。 在「Terminal」, 執行下面指令,產生「/tmp/js/gjs/lib」這個資料夾。
執行下面指令,產生「/tmp/js/gjs/main.js」這個檔案。 cat > /tmp/js/gjs/main.js <<EOF #!/usr/bin/env gjs imports.searchPath.push('/tmp/js/gjs/lib'); imports.agent.hi(); EOF 執行下面指令,觀看「/tmp/js/gjs/main.js」這個檔案的內容
顯示 #!/usr/bin/env gjs imports.searchPath.push('/tmp/js/gjs/lib'); imports.agent.hi(); 直接執行
或是執行下面指令,更改成可執行
然後就可以執行下面指令
就會在畫面上方中間,出現一個提示訊息對話框。 ================================================================================ ## 範例三 接續著「範例二」,除了可以使用「imports.searchPath」,還有一個環境變數「GJS_PATH」可以善用。 關於「GJS_PATH」可以在「gjs/gjs/importer.cpp」找到相關的實作。 執行下面指令,產生「/tmp/js/gjs/call.js」這個檔案。 cat > /tmp/js/gjs/call.js <<EOF #!/usr/bin/env gjs imports.agent.hi(); EOF 執行下面指令,觀看「/tmp/js/gjs/call.js」這個檔案的內容
顯示 #!/usr/bin/env gjs imports.agent.hi(); 直接執行
顯示
加上「GJS_PATH」這個環境變數。 執行下面指令
這樣就會正常運作了,也就是畫面上方會出現提示訊息對話框。 下面兩種寫法也可以
或
接著一樣把「/tmp/js/gjs/call.js」改為可執行 執行下面指令
一樣直接執行
會顯示
加上環境變數
就會正常運作了 下面兩種寫法,一樣可行
或
接下來,不想一直重複輸入那麼長的指令,也可以把剛剛的指令寫在「shell script」裡。 執行下面指令,產生一個檔案「/tmp/js/gjs/call.sh」 cat > /tmp/js/gjs/call.sh <<EOF #!/usr/bin/env bash GJS_PATH=/tmp/js/gjs/lib /tmp/js/gjs/call.js EOF 執行下面指令,將「/tmp/js/gjs/call.sh」設定為可執行。
接著就可以執行
接下來,除了可以將「/tmp/js/gjs/」附加到「PATH」的環境變數的作法。 可以在「/etc/environment」修改。 也可以作一個「symbolic link」連到「/tmp/js/gjs/call.sh」 將該「symbolic link」放在「PATH」這個環境變數包含的路徑裡, 執行
顯示
第一個「/home/user/bin」應該是在「~/.profile」附加的, 其餘後面的則是在「/etc/environment」, 若是有其他的,就要看您的環境,在何處有再額外設定PATH這個環境變數了。 建議放置的地方,有下面兩個 * 個人區域:「~/bin」 * 系統全域:「/usr/local/bin」 以放在「~/bin」為例, 執行下面指令,產生「~/bin/demo」
執行下面指令確認(這個步驟不是非必須)
顯示
這時候我們就可以直接執行下面指令
就會出現提示訊息對話框。 整個流程,順序就是「dmeo」 -> 「~/bin/dmeo」-> 「/tmp/js/gjs/call.sh」-> 「/tmp/js/gjs/call.js」->「/tmp/js/gjs/lib/agent.js」。 接著將「~/bin/demo」刪除,
然後以放在「/usr/local/bin」為例 執行下面指令,產生「/usr/local/bin/demo」
執行下面指令確認(這個步驟不是非必須)
顯示
這時候就可以執行下面指令
就會出現提示訊息對話框。 整個流程,順序就是「dmeo」 -> 「/usr/local/bin/demo」-> 「/tmp/js/gjs/call.sh」-> 「/tmp/js/gjs/call.js」->「/tmp/js/gjs/lib/agent.js」。 在進一步,也可以產生「Desktop Entry」。 建議放置為的資料夾如下 * 個人區域: ~/.local/share/applications * 系統全域: /usr/share/applications 執行下面指令,產生「~/.local/share/applications/demo.desktop」 mkdir ~/.local/share/applications -p cat > ~/.local/share/applications/demo.desktop <<EOF [Desktop Entry] Type=Application Name=Demo Comment=Demo Desktop Application Exec=demo Icon=application-x-executable Terminal=false EOF 然後在「Activities / Search」或是「Activities / All Applications」那裡就可以找到「啟動圖示」。 整個流程,順序就是「~/.local/share/applications/demo.desktop」 -> 「dmeo」 -> 「~/bin/dmeo」-> 「/tmp/js/gjs/call.sh」-> 「/tmp/js/gjs/call.js」->「/tmp/js/gjs/lib/agent.js」。 ================================================================================ 執行
執行
執行
顯示
可以執行「vi /usr/lib/gnome-shell/libgnome-shell.so」然後捲到下方,就可以看到一些「javascript」的「code」。 其他兩個檔案也是如此。 ================================================================================ 執行
執行
顯示
執行
* https://github.com/GNOME/gnome-shell/blob/master/src/shell-global.c#L323 ================================================================================ 執行
顯示 gnome-shell-3.26.1/js/ ├── extensionPrefs │ └── main.js ├── gdm │ ├── authPrompt.js │ ├── batch.js │ ├── fingerprint.js │ ├── loginDialog.js │ ├── oVirt.js │ ├── realmd.js │ └── util.js ├── js-resources.gresource.xml ├── meson.build ├── misc │ ├── config.js.in │ ├── desktop.js │ ├── extensionUtils.js │ ├── fileUtils.js │ ├── gnomeSession.js │ ├── history.js │ ├── ibusManager.js │ ├── jsParse.js │ ├── keyboardManager.js │ ├── loginManager.js │ ├── meson.build │ ├── modemManager.js │ ├── objectManager.js │ ├── params.js │ ├── permissionStore.js │ ├── smartcardManager.js │ ├── systemActions.js │ ├── util.js │ └── weather.js ├── perf │ ├── core.js │ └── hwtest.js ├── portalHelper │ └── main.js └── ui ├── accessDialog.js ├── altTab.js ├── animation.js ├── appDisplay.js ├── appFavorites.js ├── audioDeviceSelection.js ├── background.js ├── backgroundMenu.js ├── boxpointer.js ├── calendar.js ├── checkBox.js ├── closeDialog.js ├── components │ ├── automountManager.js │ ├── autorunManager.js │ ├── __init__.js │ ├── keyring.js │ ├── networkAgent.js │ ├── polkitAgent.js │ └── telepathyClient.js ├── ctrlAltTab.js ├── dash.js ├── dateMenu.js ├── dialog.js ├── dnd.js ├── edgeDragAction.js ├── endSessionDialog.js ├── environment.js ├── extensionDownloader.js ├── extensionSystem.js ├── focusCaretTracker.js ├── grabHelper.js ├── ibusCandidatePopup.js ├── iconGrid.js ├── inhibitShortcutsDialog.js ├── keyboard.js ├── layout.js ├── lightbox.js ├── lookingGlass.js ├── magnifierDBus.js ├── magnifier.js ├── main.js ├── messageList.js ├── messageTray.js ├── modalDialog.js ├── mpris.js ├── notificationDaemon.js ├── osdMonitorLabeler.js ├── osdWindow.js ├── overviewControls.js ├── overview.js ├── padOsd.js ├── panel.js ├── panelMenu.js ├── pointerWatcher.js ├── popupMenu.js ├── remoteMenu.js ├── remoteSearch.js ├── runDialog.js ├── screencast.js ├── screenShield.js ├── screenshot.js ├── scripting.js ├── search.js ├── sessionMode.js ├── shellDBus.js ├── shellEntry.js ├── shellMountOperation.js ├── slider.js ├── status │ ├── accessibility.js │ ├── bluetooth.js │ ├── brightness.js │ ├── keyboard.js │ ├── location.js │ ├── network.js │ ├── nightLight.js │ ├── power.js │ ├── rfkill.js │ ├── screencast.js │ ├── system.js │ └── volume.js ├── switcherPopup.js ├── switchMonitor.js ├── tweener.js ├── unlockDialog.js ├── userWidget.js ├── viewSelector.js ├── windowAttentionHandler.js ├── windowManager.js ├── windowMenu.js ├── workspace.js ├── workspacesView.js ├── workspaceSwitcherPopup.js ├── workspaceThumbnail.js └── xdndHandler.js 8 directories, 126 files ================================================================================ 在「Looking Glass / Evaluator」, 執行下面指令
顯示
其他的依此類推 * imports.ui.main.__file__ <=> resource:///org/gnome/shell/ui/main.js * imports.ui.environment.__file__ <=> resource:///org/gnome/shell/ui/environment.js * imports.ui.lookingGlass.__file__ <=> resource:///org/gnome/shell/ui/lookingGlass.js * imports.ui.runDialog.__file__ <=> resource:///org/gnome/shell/ui/runDialog.js * imports.misc.fileUtils.__file__ <=> resource:///org/gnome/shell/misc/fileUtils.js 然後對到「gnome-shell」的「Source Package」。 * imports.ui.main <=> gnome-shell-3.26.1/js/ui/main.js * imports.ui.environment <=> gnome-shell-3.26.1/js/ui/environment.js * imports.ui.lookingGlass <=> gnome-shell-3.26.1/js/ui/lookingGlass.js * imports.ui.runDialog <=> gnome-shell-3.26.1/js/ui/runDialog.js * imports.misc.fileUtils <=> gnome-shell-3.26.1/js/misc/fileUtils.js 舉例來說 在「Looking Glass / Evaluator」執行,
就會顯示一個對話框,這個對話框,跟按下「<Alt>+F2」出現的對話框是一樣的。 從上面歸納的「imports.ui.main <=> gnome-shell-3.26.1/js/ui/main.js」。 在「Terminal」,執行下面指令,
顯示 function openRunDialog() { if (runDialog == null) { runDialog = new RunDialog.RunDialog(); } runDialog.open(); } 執行
顯示
執行
顯示
* https://github.com/GNOME/gjs/blob/master/modules/lang.js * https://github.com/GNOME/gjs/blob/master/modules/_legacy.js 關於「Lang.Class」請見下方的「## imports.lang」。 ================================================================================ 另外一個例子, 在「Looking Glass / Evaluator」, 執行下面指令
就會將「Looking Glass」關閉。 在「Terminal」,執行下面指令,
顯示 function createLookingGlass() { if (lookingGlass == null) { lookingGlass = new LookingGlass.LookingGlass(); } return lookingGlass; } 執行
顯示
執行
顯示 777:var LookingGlass = new Lang.Class({ 778- Name: 'LookingGlass', 779- 780- _init : function() { 781- this._borderPaintTarget = null; 782- this._redBorderEffect = new RedBorderEffect(); * https://github.com/GNOME/gjs/blob/master/modules/lang.js * https://github.com/GNOME/gjs/blob/master/modules/_legacy.js 關於「Lang.Class」請見下方的「## imports.lang」。 另外一個額外的發現 在「Terminal」,執行下面指令,
顯示 gnome-shell-3.26.1/js/ui/main.js:510:function createLookingGlass() { gnome-shell-3.26.1/js/ui/runDialog.js:50: Main.createLookingGlass().open(); 執行
顯示 this._internalCommands = { 'lg': Lang.bind(this, function() { Main.createLookingGlass().open(); }), 'r': Lang.bind(this, this._restart), // Developer brain backwards compatibility 'restart': Lang.bind(this, this._restart), 'debugexit': Lang.bind(this, function() { Meta.quit(Meta.ExitCode.ERROR); }), // rt is short for "reload theme" 'rt': Lang.bind(this, function() { Main.reloadThemeResource(); Main.loadTheme(); }) }; 還記得 * 按下「<Alt>+F2」,然後輸入「lg」,呼叫起「Looking Glass」。 * 按下「<Alt>+F2」,然後輸入「r」,重新啟動「gnome-shell」。 ================================================================================ 額外一提一個例子,這也是我開始寫這麼多篇的契機。
顯示
================================================================================ 接下來拉回正題 執行
執行
執行
顯示 gjs └── usr ├── bin │ ├── gjs -> gjs-console │ └── gjs-console └── share └── doc └── gjs ├── changelog.Debian.gz -> ../libgjs0g/changelog.Debian.gz ├── copyright ├── NEWS.gz └── README 5 directories, 6 files 執行
顯示
執行
顯示
執行
顯示
執行
顯示
執行
顯示
執行
顯示
執行
顯示
================================================================================ 執行
執行
執行
顯示 libgjs0g └── usr ├── lib │ ├── gjs │ │ └── girepository-1.0 │ │ └── GjsPrivate-1.0.typelib │ ├── libgjs.so.0 -> libgjs.so.0.0.0 │ └── libgjs.so.0.0.0 └── share └── doc └── libgjs0g ├── changelog.Debian.gz └── copyright 7 directories, 5 files 執行
顯示
================================================================================ 執行
執行
顯示 gjs-1.50.1/gjs/importer.cpp:906: /* $GJS_PATH */ gjs-1.50.1/gjs/importer.cpp:907: envstr = g_getenv("GJS_PATH"); gjs-1.50.1/gjs/console.cpp:133: "the GJS_PATH environment variable."); gjs-1.50.1/Makefile.in:1349:# GJS_PATH is empty here since we want to force the use of our own gjs-1.50.1/Makefile.in:1354: export GJS_PATH=; \ gjs-1.50.1/Makefile-test.am:298:# GJS_PATH is empty here since we want to force the use of our own gjs-1.50.1/Makefile-test.am:303: export GJS_PATH=; \ gjs-1.50.1/NEWS:661: the search path, then you should either reorder those arguments, use GJS_PATH, 執行
顯示 888- 889-static G_CONST_RETURN char * G_CONST_RETURN * 890-gjs_get_search_path(void) 891-{ 892- char **search_path; 893- 894- /* not thread safe */ 895- 896- if (!gjs_search_path) { 897- G_CONST_RETURN gchar* G_CONST_RETURN * system_data_dirs; 898- const char *envstr; 899- GPtrArray *path; 900- gsize i; 901- 902- path = g_ptr_array_new(); 903- 904- /* in order of priority */ 905- 906- /* $GJS_PATH */ 907: envstr = g_getenv("GJS_PATH"); 908- if (envstr) { 909- char **dirs, **d; 910- dirs = g_strsplit(envstr, G_SEARCHPATH_SEPARATOR_S, 0); 911- for (d = dirs; *d != NULL; d++) 912- g_ptr_array_add(path, *d); 913- /* we assume the array and strings are allocated separately */ 914- g_free(dirs); 915- } 916- 917- g_ptr_array_add(path, g_strdup("resource:///org/gnome/gjs/modules/")); 918- 919- /* $XDG_DATA_DIRS /gjs-1.0 */ 920- system_data_dirs = g_get_system_data_dirs(); 921- for (i = 0; system_data_dirs[i] != NULL; ++i) { 922- char *s; 923- s = g_build_filename(system_data_dirs[i], "gjs-1.0", NULL); 924- g_ptr_array_add(path, s); 925- } 926- 927- /* ${datadir}/share/gjs-1.0 */ 928-#ifdef G_OS_WIN32 929- extern HMODULE gjs_dll; 930- char *basedir = g_win32_get_package_installation_directory_of_module (gjs_dll); 931- char *gjs_data_dir = g_build_filename (basedir, "share", "gjs-1.0", NULL); 932- g_ptr_array_add(path, g_strdup(gjs_data_dir)); 933- g_free (gjs_data_dir); 934- g_free (basedir); 935-#else 936- g_ptr_array_add(path, g_strdup(GJS_JS_DIR)); 937-#endif 938- 939- g_ptr_array_add(path, NULL); 940- 941- search_path = (char**)g_ptr_array_free(path, false); 942- 943- gjs_search_path = search_path; 944- } else { 945- search_path = gjs_search_path; 946- } 947- 948- return (G_CONST_RETURN char * G_CONST_RETURN *)search_path; 949-} 950- * https://github.com/GNOME/gjs/blob/master/gjs/importer.cpp#L907 ================================================================================ ## imports.lang 執行
顯示
執行
顯示 2:/* exported Class, Interface, bind, copyProperties, copyPublicProperties, 26:var {Class, Interface, getMetaClass} = imports._legacy; 執行
顯示
執行
### Class 相關文件 * https://wiki.gnome.org/Projects/Gjs/StyleGuide#Classes * https://wiki.gnome.org/Projects/GnomeShell/Gjs_StyleGuide#Classes ### GObject * https://wiki.gnome.org/Projects/Gjs/StyleGuide#GObject_Introspection * https://wiki.gnome.org/Projects/Gjs/Mapping ### MDN * JavaScript Guide / Working with objects ### Gjs * https://wiki.gnome.org/Projects/Gjs * https://wiki.gnome.org/Projects/Gjs/StyleGuide * https://wiki.gnome.org/Projects/Gjs/Documentation * https://github.com/GNOME/gjs/tree/master/examples * https://github.com/GNOME/gjs/tree/master/modules * https://github.com/GNOME/gjs/blob/master/modules/lang.js * https://github.com/GNOME/gjs/blob/master/modules/_legacy.js ### API * https://people.gnome.org/~gcampagna/docs/ * http://devdocs.baznga.org/ ================================================================================ [回到索引]
2017/10/30 21:42
|
||||||||||
![]() |
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引]
================================================================================ # 如何開發「gnome-extension」 ================================================================================ ## 路徑 * /usr/share/gnome-shell/extensions/ * ~/.local/share/gnome-shell/extensions/ ## 工具 * gnome-shell-extension-tool * gnome-shell-extension-prefs * gnome-tweak-tool * gnome-shell ## 文件 * https://wiki.gnome.org/Projects/GnomeShell/Extensions * https://wiki.gnome.org/Projects/GnomeShell/LookingGlass ## 相關討論 * 如何撰寫Gnome Shell Extension。 * Cinnamon Develop Extension Start (#8 回覆: [分享] Cinnamon 的 使用心得) ================================================================================ ## gnome-shell-extension-tool 執行
顯示 Usage: gnome-shell-extension-tool [options] Options: -h, --help show this help message and exit -d DISABLE, --disable-extension=DISABLE Disable a GNOME Shell extension -e ENABLE, --enable-extension=ENABLE Enable a GNOME Shell extension -c, --create-extension Create a new GNOME Shell extension -r RELOAD, --reload-extension=RELOAD Reload a GNOME Shell extension 執行
會先詢問「Name」
會先詢問「Description」
會先詢問「Uuid」
最後產生
================================================================================ ## demo@home 執行下面指令,觀看「~/.local/share/gnome-shell/extensions/demo@home」這個資料夾結構
顯示
================================================================================ ## metadata.json 執行下面指令,觀看「~/.local/share/gnome-shell/extensions/demo@home/metadata.json」這個檔案的內容
顯示
================================================================================ ## extension.js 執行
顯示 const St = imports.gi.St; const Main = imports.ui.main; const Tweener = imports.ui.tweener; let text, button; function _hideHello() { Main.uiGroup.remove_actor(text); text = null; } function _showHello() { if (!text) { text = new St.Label({ style_class: 'helloworld-label', text: "Hello, world!" }); Main.uiGroup.add_actor(text); } text.opacity = 255; let monitor = Main.layoutManager.primaryMonitor; text.set_position(monitor.x + Math.floor(monitor.width / 2 - text.width / 2), monitor.y + Math.floor(monitor.height / 2 - text.height / 2)); Tweener.addTween(text, { opacity: 0, time: 2, transition: 'easeOutQuad', onComplete: _hideHello }); } function init() { button = new St.Bin({ style_class: 'panel-button', reactive: true, can_focus: true, x_fill: true, y_fill: false, track_hover: true }); let icon = new St.Icon({ icon_name: 'system-run-symbolic', style_class: 'system-status-icon' }); button.set_child(icon); button.connect('button-press-event', _showHello); } function enable() { Main.panel._rightBox.insert_child_at_index(button, 0); } function disable() { Main.panel._rightBox.remove_child(button); } ================================================================================ ## stylesheet.css 執行
顯示 .helloworld-label { font-size: 36px; font-weight: bold; color: #ffffff; background-color: rgba(10,10,10,0.7); border-radius: 5px; padding: .5em; } ================================================================================ ## 如何啟用 執行
顯示
然後需要重新啟動「gnome-shell」,下面提供三種方式。 * 第一種方式,只要鍵盤按下「<Alt>+<F2>」,然後再輸入「r」,按下鍵盤「Enter」。 * 第二種方式,就是在「Terminal」,執行「gnome-shell -r」。 * 第三種方式,登出系統,然後再登入系統。 註: * 第一種方式,在「Wayland Session」無法有作用,會出現「Restart is not available on Wayland」這樣的提示訊息。 所以建議要測試時,可以在登入的時候,「Session」選擇「Ubuntu on Xorg」。 * 第二種方式,在「Wayland Session」,則為顯示「(gnome-shell:2789): mutter-WARNING **: Can't initialize KMS backend: Could not get session ID: No such file or directory」這樣的提示訊息。 * 有一種方式,我測試「gnome-shell-extension-tool -r demo@home」目前發現沒作用,這部份尚未再去深究。 ================================================================================ 除了使用「gnome-shell-extension-tool」這個工具來「啟用」「停用」「extension」 也可以改用「gnome-shell-extension-prefs」或是「gnome-tweak-tools」來「啟用」「停用」「extension」。 ================================================================================ 當啟用「demo@home」成功後, 就會在「Top Bar」看到一個設定圖示的按鈕,按了之後, 就會在畫面的正中間,顯示「Hello, world!」的提示訊息。 ================================================================================ ## 進一步測試 執行下面的指令,修改「~/.local/share/gnome-shell/extensions/demo@home/extension.js」的內容。 cat > ~/.local/share/gnome-shell/extensions/demo@home/extension.js <<EOF const Main = imports.ui.main; log("demo@home load"); Main.notify("demo@home load"); function init() { log("demo@home init"); Main.notify("demo@home init"); } function enable() { log("demo@home enable"); Main.notify("demo@home enable"); } function disable() { log("demo@home disable"); Main.notify("demo@home disable"); } EOF 執行下面指令,觀看更改後的內容
顯示 const Main = imports.ui.main; log("demo@home load"); Main.notify("demo@home load"); function init() { log("demo@home init"); Main.notify("demo@home init"); } function enable() { log("demo@home enable"); Main.notify("demo@home enable"); } function disable() { log("demo@home disable"); Main.notify("demo@home disable"); } ================================================================================ ## 測試 ### 重新啟動「gnome-shell」 接著一樣要重新啟動「gnome-shell」,採用第一種方式「<Alt>+F2」,然後輸入「r」。(我在「Ubuntu on Xorg」的環境測試) 重新啟動後, 就會先看到「demo@home load」的提示對話框,按下關閉後, 接著就會看到「demo@home init」的提示對話框,按下關閉後, 接著就會看到「demo@home enable」的提示對話框,按下關閉。 ### 測試「disable」 執行
在「Terminal」會顯示「'demo@home' is now disabled.」。 在畫面上方中間會出現「demo@home disable」的提示對話框。 ### 測試「enable」 執行
在「Terminal」會顯示「'demo@home' is now enabled.」。 在畫面上方中間會出現「demo@home enable」的提示對話框。 ### 測試「reload」 執行
會有反應, 但是若是先改了「extension.js」原始碼的訊息內容,然後再執行上面的指令,雖然會有反應 但是顯示提示的訊息,並沒有改變,感覺只是重新載入舊的。 所以在「reload」這個動作,我目前都還是執行「<Alt>+<F2>」,然後輸入「r」來達成。 經驗裡,有時候在測的時候,系統好像會錯亂,導致有些不是預期的狀況發生, 所以有時候我就會登出登入,再測看看, 再不然就是重新開機。 當然有時候是自己的Code寫錯導致的,寫的邏輯不是預期的。 所以要耐心地去釐清出錯的關鍵點在何處。 ================================================================================ 然後剛剛的測試,也可以在「/var/log/syslog」這個檔案,看到相關的「log」紀錄, 可以執行下面的指令觀看。
================================================================================ 以上只是提供入門,因為我也只有研究到這裡了 :p 其他的就要參考其他人寫好的「extension」了。 在「#34」,有套件列表,是套件庫預設有提供的。 也許可以從「gnome-shell-extension-tilix-dropdown(GitHub)」這個套件探索起,下面的「#40」會提到這個套件。 其餘的就可從下面的網址開始找起。 ### gnome-shell-extensions * https://extensions.gnome.org/ * https://github.com/GNOME/gnome-shell-extensions * https://github.com/gcampax/gnome-shell-extensions * https://packages.ubuntu.com/artful/gnome-shell-extensions ### 文件 * https://wiki.gnome.org/Projects/GnomeShell/Extensions * https://wiki.gnome.org/Projects/GnomeShell/LookingGlass ### gnome-shell * https://github.com/GNOME/gnome-shell/tree/master/js ### gjs * https://github.com/GNOME/gjs/tree/master/modules 註: 關於「gjs」,我在「#32」的下方,有列一些參考連結。 ### cinnamon * https://cinnamon-spices.linuxmint.com/extensions * https://github.com/linuxmint ================================================================================ 接下來要探索『如何透過安裝套件的方式,安裝額外的「gnome-extension」』。 ================================================================================ [回到索引]
2017/10/30 21:52
|
||||||||||
![]() |
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引]
================================================================================ # 如何透過安裝套件的方式,安裝額外的「gnome-shell-extension」 ================================================================================ ## 探索開始 執行
顯示
執行
顯示
或是也可以執行「$ apt-cache pkgnames gnome-shell-extension」 ================================================================================ ## 套件列表 * gnome-shell-extension-appindicator * gnome-shell-extension-ubuntu-dock * gnome-shell-extension-autohidetopbar * gnome-shell-extension-better-volume * gnome-shell-extension-caffeine * gnome-shell-extension-dash-to-panel * gnome-shell-extension-dashtodock * gnome-shell-extension-disconnect-wifi * gnome-shell-extension-hard-disk-led * gnome-shell-extension-hide-activities * gnome-shell-extension-impatience * gnome-shell-extension-log-out-button * gnome-shell-extension-mediaplayer * gnome-shell-extension-move-clock * gnome-shell-extension-multi-monitors * gnome-shell-extension-onboard * gnome-shell-extension-pixelsaver * gnome-shell-extension-redshift * gnome-shell-extension-remove-dropdown-arrows * gnome-shell-extension-shortcuts * gnome-shell-extension-show-ip * gnome-shell-extension-suspend-button * gnome-shell-extension-system-monitor * gnome-shell-extension-taskbar * gnome-shell-extension-tilix-dropdown * gnome-shell-extension-top-icons-plus * gnome-shell-extension-trash * gnome-shell-extension-weather * gnome-shell-extensions * gnome-shell-extensions-gpaste 上面列表的BBCode原始碼,是執行下面指令產生的。
或是也可以執行下面指令產生 #!/usr/bin/env bash for PACKAGE in $(apt-cache search gnome-shell-extension | cut -d ' ' -f 1 | grep gnome-shell-extension) ; do #echo $PACKAGE echo "* $PACKAGE" done ================================================================================ 也可以執行下面的指令
或是執行下面的指令 #!/usr/bin/env bash for PACKAGE in $(apt-cache search gnome-shell-extension | cut -d ' ' -f 1 | grep gnome-shell-extension) ; do #echo $PACKAGE echo "$ sudo apt-get install $PACKAGE" done 產生下面的列表
================================================================================ ## 單一安裝 以安裝「gnome-shell-extension-shortcuts」這個套件為例。
================================================================================ ## 全部安裝 執行下面指令
================================================================================ ## 選用安裝 先執行下面指令,產生一個檔案「package.list」
然後執行下面指令,編輯「package.list」
刪除不想安裝套件的那行。 最後再執行下面指令安裝。
================================================================================ ## 安裝完後套件,如何確認是否已經安裝 以安裝「gnome-shell-extension-shortcuts」這個套件為例。 執行下面指令,安裝「gnome-shell-extension-shortcuts」這個套件。
安裝完畢後,可以執行下面指令確認
顯示 Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/[/color] Name Version Architecture Description +++-======================================-========================-========================-====== ii gnome-shell-extension-shortcuts 1.1.0-1 all Creates a shortcuts help pop-up in GNOME Shell 或是也可以執行下面指令確認
若是已經安裝,會顯示如下
然後可以執行下面指令,了解到這個套件有安裝那些檔案在系統上
顯示
可以了解到「gnome-shell-extension-shortcuts」這個套件,裡面包含的「gnome extension」, 安裝在「/usr/share/gnome-shell/extensions/Shortcuts@kyle.aims.ac.za」這個資料夾。 執行
顯示
================================================================================ 上面列的套件,裡面包含的「gnome extension」, 應該都是安裝在「/usr/share/gnome-shell/extensions」這個資料夾。 可以執行下面指令,觀看「/usr/share/gnome-shell/extensions」這個資料夾。
================================================================================ 安裝完畢後, 鍵盤按下「<Alt>+<F2>」,會跳出一個「Enter Command」的對話框, 然後在該對話框,輸入「r」,重新啟動「gnome-shell」。 上面這個方式在,「Wayland Session」是無效的。 所以就必須要「登出系統」再「登入」。 接著可以透過「gnome-shell-extension-prefs」這個工具來「啟用」或「停用」「Extension」。 若有安裝「gnome-tweak-tool」這個套件, 執行「gnome-tweak-tool」,在「Extensions」那個頁簽,也會顯示「gnome-shell-extension-prefs」的畫面。 執行「gnome-shell-extension-prefs」的方式, 一種方式,可以先開啟「Terminal」,快速鍵是「<Ctrl>+<Alt>+T」,然後就可以輸入「gnome-shell-extension-prefs」,接著鍵盤按下「Enter」。 另一種方式,鍵盤按下「<Alt>+<F2>」,會跳出一個「Enter Command」的對話框,然後輸入「gnome-shell-extension-prefs」,接著鍵盤按下「Enter」。 在「Activities / Search」那無法搜尋到。 原因出在「/usr/share/applications/gnome-shell-extension-prefs.desktop」這個檔案的設定, 執行
顯示
可以執行下面指令,將「/usr/share/applications/gnome-shell-extension-prefs.desktop」 複製到「~/.local/share/applications/gnome-shell-extension-prefs.desktop 」,然後修改。
執行下面指令,確認是否修改了「~/.local/share/applications/gnome-shell-extension-prefs.desktop 」
顯示
這樣就可以在在「Activities / Search」那輸入「Shell」那關鍵字,就可以找到「gnome-shell-extension-prefs」的「啟動圖示」。 ================================================================================ 關於「gnome-shell-extension-prefs」是屬於「gnome-shell」這個套件。 執行
顯示
執行
顯示
或是也可以執行
顯示
================================================================================ ## 我目前安裝的套件 執行
顯示 ii gnome-shell-extension-appindicator 17.10.1 all App indicators for GNOME Shell ii gnome-shell-extension-shortcuts 1.1.0-1 all Creates a shortcuts help pop-up in GNOME Shell ii gnome-shell-extension-system-monitor 32-3 all Display system information in GNOME Shell status bar ii gnome-shell-extension-taskbar 56.0-1 all TaskBar Extension for GNOME Shell ii gnome-shell-extension-tilix-dropdown 5.1-1 all launch tilix in quake-mode from gnome-shell ii gnome-shell-extension-ubuntu-dock 0.7 all Ubuntu Dock for GNOME Shell ii gnome-shell-extension-weather 0~20170402.git34506a6-1 all weather extension for GNOME Shell ii gnome-shell-extensions 3.26.1-1 all Extensions to extend functionality of GNOME Shell 執行
顯示
上面列表的BBCode原始碼,是執行下面指令產生的。 #!/usr/bin/env bash for PACKAGE in $(dpkg -l '*gnome-shell-extension*' | grep '^ii' | cut -d ' ' -f 3) ; do #echo $PACKAGE echo "$PACKAGE" done 也可以執行下面指令產生
================================================================================ ## gnome-shell-extensions 要注意,關於「gnome-shell-extensions」這個套件,裡面包含了多個套件。 在還沒安裝之前,可以下載「deb檔」下來,先解開來探索。 或是到「GitHub」上觀看。 執行
會下載一個檔案「gnome-shell-extensions_3.26.1-1_all.deb」。 執行下面指令解開
會產生一個資料夾「gnome-shell-extensions」。 執行
顯示
上面列表的BBCode原始碼,是執行下面指令產生的。
或是執行下面指令產生
執行下面指令,則是可以觀看「gnome-shell-extensions/usr/share/gnome-shell/extensions/」的資料夾結構。
顯示
================================================================================ [回到索引]
2017/10/30 22:04
|
||||||||||
![]() |
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引] - [備份連結]
================================================================================ # 如何查詢「gedit」的快速鍵 ================================================================================ 先執行「gedit」, 然後在系統的上方「TopBar」,點選「gedit」的「Applicaion Menu」,會出現一個下拉選單, 有一個選項「Keyboard Shortcuts」,點選它, 就會出現一個標題為「Shortcuts」的視窗。 下方有三個按鈕「1」,「2」,「3」,按下可以切換不同頁面。 左上方有一個「搜尋圖示」的按鈕,按下後,就會出現一個「文字輸入框」,在那輸入關鍵字,就會顯示相關的。 ================================================================================ [回到索引] - [備份連結]
2017/10/30 22:06
|
||||||||||
![]() |
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引] - [備份連結]
================================================================================ # 如何透過安裝套件的方式,安裝額外的「gedit-plugin」 ================================================================================ ## 測試環境 執行
顯示
執行
顯示
================================================================================ ## 探索起點 執行
顯示 gedit-plugin-bookmarks - Bookmarks plugin for gedit gedit-plugin-bracket-completion - Bracket Completion plugin for gedit gedit-plugin-character-map - Character Map plugin for gedit gedit-plugin-code-comment - Code Comment plugin for gedit gedit-plugin-color-picker - Color Picker plugin for gedit gedit-plugin-color-schemer - Color Schemer plugin for gedit gedit-plugin-commander - Commander plugin for gedit gedit-plugin-dashboard - Dashboard plugin for gedit gedit-plugin-draw-spaces - Draw Spaces plugin for gedit gedit-plugin-find-in-files - Find in Files plugin for gedit gedit-plugin-git - Git plugin for gedit gedit-plugin-join-lines - Join/Split Lines plugin for gedit gedit-plugin-multi-edit - Multi Edit plugin for gedit gedit-plugin-smart-spaces - Smart Spaces plugin for gedit gedit-plugin-synctex - SyncTex plugin for gedit gedit-plugin-terminal - Terminal plugin for gedit gedit-plugin-text-size - Text Size plugin for gedit gedit-plugin-word-completion - Word Completion plugin for gedit gedit-plugin-zeitgeist - Zeitgeist plugin for gedit gedit-plugins - set of plugins for gedit gedit-plugins-common - common files for gedit-plugins ================================================================================ ## 單一安裝 舉例 執行下面指令安裝「gedit-plugin-find-in-files」
然後在系統的上方「TopBar」,點選「gedit」的「Applicaion Menu」,會出現一個下拉選單, 有一個選項「Preferences」,點選它, 就會出現一個標題為「Preferences」的設定視窗,有四個頁簽(tab),分別是 * View * Editor * Font & Colors * Plugins 選「Plugins」,切換到該頁簽的內容, 就可以找到一個選項 標題:「Find in Files」 簡述:「Find text in all files of a folder」 勾選這個選項,就可以啟用「gedit-plugin-find-in-files (Find in Files)」這個「gedit-plugin」。 接著請把「Preferences」這個視窗關閉。 然後在「gedit」的主視窗,右上方,有一個「三條橫槓」圖示的「按鈕」, 按下後,就會出現一個下拉選單,可以看到其中有一個選項「Find in Files...」, 點選「Find in Files...」這個選項,就會跳出一個標題為「Find in Files...」的對話框。 ================================================================================ ## 全部安裝 執行下面指令
安裝「gedit-plugins」這套件,就會安裝所有的「gedit-plugin」。 可以執行下面指令,就可以了解到會安裝那些「gedit-plugin」。
顯示
執行下面指令,拆成列表來觀看
顯示
上面連結列表的原始碼,則是執行下面指令產生的。
或是執行下面指令 #!/usr/bin/env bash for PACKAGE in $(apt-cache show gedit-plugins | grep '^Depends:' | awk -F ': ' '{print $2}' | sed 's/, /\n/g'); do #echo $PACKAGE echo "$PACKAGE" done ================================================================================ ## Source Package: gedit-plugins 執行
顯示
可以了解到這些單一套件,都是來自於「gedit-plugins」這個「Source Package」。 ================================================================================ ## Package: gedit-plugins-common 而其中有一個套件「gedit-plugins-common」,當安裝這些單一套件,就會一併安裝。
顯示
執行
顯示 gedit-plugins-common Reverse Depends: gedit-plugin-bookmarks gedit-plugin-zeitgeist gedit-plugin-word-completion gedit-plugin-text-size gedit-plugin-terminal gedit-plugin-synctex gedit-plugin-smart-spaces gedit-plugin-multi-edit gedit-plugin-join-lines gedit-plugin-git gedit-plugin-find-in-files gedit-plugin-draw-spaces gedit-plugin-dashboard gedit-plugin-commander gedit-plugin-color-schemer gedit-plugin-color-picker gedit-plugin-code-comment gedit-plugin-character-map gedit-plugin-bracket-completion ================================================================================ ## Package: gedit-plugin-find-in-files 以安裝「gedit-plugin-find-in-files」為例。 執行
顯示 /. /usr /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/gedit /usr/lib/x86_64-linux-gnu/gedit/plugins /usr/lib/x86_64-linux-gnu/gedit/plugins/findinfiles.plugin /usr/lib/x86_64-linux-gnu/gedit/plugins/libfindinfiles.so /usr/share /usr/share/doc /usr/share/doc/gedit-plugin-find-in-files /usr/share/doc/gedit-plugin-find-in-files/copyright /usr/share/metainfo /usr/share/metainfo/gedit-findinfiles.metainfo.xml /usr/share/doc/gedit-plugin-find-in-files/changelog.Debian.gz 可以注意到三個檔案路徑 * /usr/lib/x86_64-linux-gnu/gedit/plugins/findinfiles.plugin * /usr/lib/x86_64-linux-gnu/gedit/plugins/libfindinfiles.so * /usr/share/metainfo/gedit-findinfiles.metainfo.xml 和注意到兩個資料夾路徑 * /usr/lib/x86_64-linux-gnu/gedit/plugins * /usr/share/metainfo 執行
顯示 [Plugin] Module=findinfiles IAge=3 Name=Find in Files Name[ar]=ابحث في الملفات Name[ca]=Cerca als fitxers Name[cs]=Hledat v souborech Name[de]=In Dateien suchen Name[el]=Εύρεση σε αρχεία Name[es]=Buscar en archivos Name[he]=חיפוש בקבצים Name[hu]=Keresés fájlokban Name[id]=Cari dalam Berkas Name[it]=Cerca nei file Name[ko]=파일에서 찾기 Name[lt]=Rasti failuose Name[lv]=Meklēt datnēs Name[pl]=Wyszukiwanie w plikach Name[pt]=Localizar em ficheiros Name[pt_BR]=Localizar no Arquivos Name[sk]=Nájdenie v súboroch Name[sr]=Пронађи у датотекама Name[sr@latin]=Pronađi u datotekama Name[sv]=Sök i filer Name[th]=หาในแฟ้ม Name[tr]=Dosyalarda Bul Name[zh_CN]=在文件中查找 Description=Find text in all files of a folder. Description[ar]=ابحث عن نص في كل الملفات في مجلد. Description[ca]=Cerca text en tots els fitxers d'una carpeta. Description[cs]=Hledá text ve všech souborech ve složce. Description[de]=Text in allen Dateien eines Ordners suchen. Description[el]=Εύρεση κειμένου σε όλα τα αρχεία ενός φακέλου. Description[es]=Buscar texto en todos los archivos o en un carpeta. Description[he]=מציאת טקסט בכל הקבצים בתיקייה. Description[hu]=Szöveg keresése egy mappa minden fájljában. Description[id]=Cari teks dalam semua berkas pada suatu folder. Description[it]=Cerca il testo in tutti i file di una cartella. Description[ko]=폴더의 모든 파일에서 문자열 찾기 Description[lt]=Rasti tekstą visuose aplanko failuose. Description[lv]=Meklēt tekstu visās datnēs un mapēs. Description[pl]=Wyszukiwanie tekstu we wszystkich plikach w katalogu. Description[pt]=Localizar texto em todos os ficheiros de uma pasta. Description[pt_BR]=Localizar texto em todos os arquivos de uma pasta. Description[sk]=Nájde text vo všetkých súboroch priečinka. Description[sr]=Пронађите текст у свим датотекама у фасцикли. Description[sr@latin]=Pronađite tekst u svim datotekama u fascikli. Description[sv]=Sök text i alla filer för en mapp. Description[th]=หาข้อความในแฟ้มทั้งหมดของโฟลเดอร์ Description[tr]=Klasörün bütün dosyalarında metin bul. Description[zh_CN]=在文件夹的所有文件查找文本 Authors=The Lemon Man <thatlemon at google's mail service dot com> Copyright=Copyright © 2015 The Lemon Man Website=http://www.gedit.org Version=3.22.0 執行
顯示 <?xml version="1.0" encoding="UTF-8"?> <component type="addon"> <id>gedit-findinfiles</id> <extends>org.gnome.gedit.desktop</extends> <name>Find in Files</name> <summary>Find text in all files of a folder</summary> <url type="homepage">https://wiki.gnome.org/Apps/Gedit/ShippedPlugins</url> <url type="bugtracker">https://bugzilla.gnome.org/enter_bug.cgi?product=gedit&component=Plugins</url> <metadata_license>CC0-1.0</metadata_license> <project_license>GPL-2.0+</project_license> <updatecontact>i.gnatenko.brain@gmail.com</updatecontact> </component> 執行
顯示
$ ls /usr/lib/x86_64-linux-gnu/gedit/plugins $ ls /usr/share/metainfo 執行
顯示
可以了解到有那些套件,安裝在「/usr/lib/x86_64-linux-gnu/gedit/plugins」這個資料夾。 ================================================================================ [回到索引] - [備份連結]
2017/10/30 22:11
|
||||||||||
![]() |
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引] - [備份連結]
================================================================================ # 設定讓「gedit」,可以辨識「big5編碼的檔案」 ================================================================================ ## 相關討論 * #2 回覆: gedit 亂碼問題 * #3 回覆: GEDIT復製WIN7的TXT檔案打開後變亂碼 (16.04) ## 相關索引 * [索引] 文件編碼 ================================================================================ 以下測試環境 * gedit: 3.22.1 * gsettings: 2.54.1 ================================================================================ ## 初步探索 執行
顯示
================================================================================ ## get 執行下面指令,觀看「candidate-encodings」目前的設定值
顯示
================================================================================ ## set 執行下面指令,設定「candidate-encodings」的值
執行下面指令,觀看「candidate-encodings」目前的設定值
顯示
================================================================================ ## reset 執行下面指令,恢復「candidate-encodings」的預設值
執行下面指令,觀看「candidate-encodings」目前的設定值
顯示
================================================================================ 關於「candidate-encodings」的預設值,可以在「/usr/share/glib-2.0/schemas/org.gnome.gedit.gschema.xml」這個檔案找到。 執行
顯示 <schema gettext-domain="gedit" id="org.gnome.gedit.preferences.encodings" path="/org/gnome/gedit/preferences/encodings/"> <key name="candidate-encodings" type="as"> <default>['']</default> <summary>Candidate Encodings</summary> <description>List of candidate encodings shown in the Character Encoding menu in the open/save file chooser. "CURRENT" represents the current locale encoding. Only recognized encodings are used. The default value is the empty list, in which case gedit will choose good defaults depending on the country and language.</description> </key> </schema> 若要得到「default value」,除了上面可以「reset」再「get」。 也可以執行下面指令,直接從「/usr/share/glib-2.0/schemas/org.gnome.gedit.gschema.xml」撈取出來。
顯示
或是執行下面指令,直接從「/usr/share/glib-2.0/schemas/org.gnome.gedit.gschema.xml」撈取出來。
顯示
================================================================================ 上面是透過下指令的方式,來設定「gsettings」。 也可以透過圖形工具來操作,可以透過「dconf-editor」來設定 而「dconf-editor」是屬於「dconf-editor」這個套件。 執行
或是執行
然後執行「dconf-editor」,使用「candidate-encodings」當關鍵字查詢,就可以找到該筆資料,來維護。 ================================================================================ 另外在「gedit」那也可以設定, 在「gedit」的主視窗,右上方,有一個「三條橫槓」圖示的「按鈕」, 按下後,就會出現一個下拉選單,可以看到其中有一個選項「Save As...」, 點選「Save As...」這個選項,就會跳出一個對話框。 在對話框左下方有一個選項,「Character Encoding:」, 請先下拉選單, 然後捲動到最下方,會有一個選項「Add or Remove...」, 點選它,就會出現另一個標題為「Character Encoding」的對話框, 在這個對話框,就可以維護(新增,刪除,排序)。 在「gedit」的主視窗,左上方有一個按鈕「Open」,按下後,會出現一個下拉選單, 在下拉選單下方,有一個按鈕「Other Documents...」,按下後,會出現一個標題為「Open」的對話框, 或是也可以直接使用快速鍵「<Ctrl>+o」,一樣會出現標題為「Open」的對話框, 再來的操作步驟,就如同剛剛上面介紹的。 ================================================================================ ## 測試步驟 執行下面指令,先產生一個檔案「utf-8.txt」。
執行下面指令,觀看「utf-8.txt」的檔案內容
顯示
執行
顯示
執行下面指令,將「utf-8.txt」的檔案內容,轉成「big5」編碼,並且輸出到「big5.txt」
執行下面指令,觀看「big5.txt」的檔案內容
顯示(亂碼)
執行
顯示
執行
執行
顯示
執行
顯示
這些工具有紀錄在「[索引] 文件編碼」。 回到正題, 直接點選「big5.txt」用「gedit」打開,可以看到正常顯示,不會出現亂碼 或是也可以直接執行「$ gedit big5.txt」,一樣會用「gedit」開啟「big5.txt」。 ================================================================================ [回到索引] - [備份連結]
2017/10/30 22:15
|
||||||||||
![]() |
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引] - [備份連結]
================================================================================ # 關於「gedit」的「color scheme」 ================================================================================ ## 如何找到「org.gnome.gedit.preferences.editor scheme」 執行
顯示
================================================================================ ## get 執行
================================================================================ ## set 執行
我是設定「oblivion」, 也可以透過「Gedit / Application Menu / Preferences / 」的「Font & Colors / Color Scheme」那來設定。 另外下面會有更多的說明,說明如何找到『可用「color scheme」列表』。 ================================================================================ ## reset 執行
================================================================================ ## 預設值定義 執行
顯示 <key name="scheme" type="s"> <default>'classic'</default> <summary>Style Scheme</summary> <description>The ID of a GtkSourceView Style Scheme used to color the text.</description> </key> ================================================================================ ## 如何找到「color scheme」的定義檔。 若有安裝「gnome-builder」這個套件, 在「gedit」的「color scheme」也可以設定「builder-dark」或是「builder」。 執行下面指令,設定「builder-dark」。
執行下面指令,設定「builder」。
回到原本要討論的,如何找到「color scheme」的定義檔。 執行
顯示
可以找到「/usr/share/gtksourceview-3.0/styles/」這個資料夾 執行
顯示
執行下面指令,了解「/usr/share/gtksourceview-3.0/styles」裡面的檔案,是來自於那些套件。
顯示
表示「/usr/share/gtksourceview-3.0/styles」裡面的檔案,是來自「gnome-builder」和「libgtksourceview-3.0-common」這兩個套件。 執行
顯示
所以可以找到「libgtksourceview-3.0-common」這個套件。 因為我一開始在「gedit」和「gedit-common」這兩個套件找尋,並沒有找到「color scheme」的定義檔。 ================================================================================ ## 可用「color scheme」列表 執行
顯示
執行下面指令
或是執行下面指令 #!/usr/bin/env bash for SCHEME in $(ls /usr/share/gtksourceview-3.0/styles -1 | cut -d '.' -f 1) ; do #echo $SCHEME echo '$' "gsettings set org.gnome.gedit.preferences.editor scheme '$SCHEME'" done 顯示
================================================================================ [回到索引] - [備份連結]
2017/10/30 22:19
|
||||||||||
![]() |
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引]
================================================================================ # gnome-builder ================================================================================ ## 安裝 執行下面指令,安裝「gnome-builder」
================================================================================ [回到索引]
2017/10/30 22:22
|
||||||||||
![]() |
回覆: Ubuntu 17.10 推出 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
[回到索引]
================================================================================ # 關於「tilix」 ================================================================================ 發現到在「17.04」的套件庫,預設有提供「tilix (GitHub)」了 。 執行下面指令,安裝「tilix」這個套件。
================================================================================ 並且還有發現一個「gnome-shell-extension」,套件是「gnome-shell-extension-tilix-dropdown」。 執行
顯示
執行下面指令,安裝「gnome-shell-extension-tilix-dropdown」這個套件。
至於如何啟用新的「Extension」,請參考上面的「#33」和「#34」 啟用後,「TopBar」會有一個按鈕,可以呼叫出「Tilix」的「quake」模式。 也可以使用快速鍵,預設應該是「F10」,可以自訂, 可以執行「gnome-tewak-tool」或「gnome-shell-extension-prefs」 找到「Tilix dropdown」,在那有一個設定按鈕,按下之後,就會出現一個新的對話框,在那裡就可以設定。 ================================================================================ 關於「Tilix」的「quake」模式,只是執行「tilix --quake」這個指令,就會作切換了, 在別的桌面環境,可以設定快速鍵來對應。 若沒有安裝「gnome-shell-extension-tilix-dropdown」這個套件。 可以採用這個方式,到「Settings / Keyboard」那設定。 啟動「Settings / Keyboard」的方式如下: * 方式一: 按下鍵盤「<Super>」鍵,或是左上方的「Activities」按鈕,就會進到「Overview」, 在「Type to search...」那輸入「keyboard」,就會找到「Settings / Keyboard」的「啟動圖示」。 * 方式二: 按下鍵盤「<Alt>+F2」,會出現「Run Command」對話框,輸入「gnome-control-center keyboard」, 就會跳出「Keyboard 設定視窗」。 * 方式三: 在「Terminal」執行「$ gnome-control-center keyboard」,就會跳出「Keyboard 設定視窗」。 跳出「Keyboard 設定視窗」後,捲動到最下方, 會有一個「+」的圖示按鈕,按下後,會跳出另一個標題為「Add Custom Shortcut」的對話框。 有兩個欄位可以輸入 * Name: Tilix * Command: tilix --quake 然後按下「Set Shortcut..」,會切換到另一個畫面「Enter the new shortcut」,按下「F10」,就會回到剛剛輸入欄位的畫面, 就會在「Shortcut」這個欄位,變成「Shortcut: F10」。 然後按下右上角的「Add」按鈕,就會新增一筆設定,在最下方的「Cuttom Shortcuts」。 這時候按下「F10」,就可以測試「tilix --quake」是否會出現。 註: 我個人是設定「F9」。 ================================================================================ ## Homepage 執行
顯示
執行
顯示
================================================================================ ## Quake 可以參考「Tilix / Documentation / Quake」。 探索「gnome-shell-extension-tilix-dropdown」這個套件。 執行
顯示 40- 41-function _startTilix() { 42- try { 43: Main.Util.trySpawnCommandLine('tilix --quake'); 44- } catch(err) { 45- Main.notify("Couldn't start tilix, is it installed?"); 46- } 47-} 48- ## 快速鍵 (F10)
顯示
================================================================================ ## integrate with Nautilus 執行
顯示
因為看到了「/usr/share/nautilus-python/extensions/open-tilix.py」這個檔案,但發現好像沒有作用。 所以稍微研究了一下。 執行
顯示
執行
顯示 Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-======================================-========================-========================-====== un python-nautilus <none> <none> (no description available) 發現到「python-nautilus」尚未安裝在系統上。 執行下面指令,觀看「python-nautilus」這個套件相關的資訊。
顯示
執行下面指令,安裝「python-nautilus」這個套件。
然後開啟「nautilus」,在資料夾(目前開啟的,或是資料夾圖示),按下右鍵,出現一個選單, 就會出現「Open Tilix Here」的選項。 點選之後,就會開啟「tilix」,並且切換到該資料夾。 ================================================================================ 另外額外一提的,我有稍微測試過「Ubuntu Budgie 17.10」,發現預設的「Terminal」是採用「Tilix」。 從上面的「apt-cache search tilix」, 第一筆是「budgie-desktop-environment - Desktop environment customisation for Ubuntu Budgie」 然後再執行
顯示
================================================================================ ## 相關文章 * The D Blog / On Tilix and D: An Interview with Gerald Nunn * Why D is the Perfect Fit for Building GTK Applications (影片) (投影片) * Learning D and GTK * Creating Complex Popovers in D and GtkD * GtkD and Localization * Using the GAction Framework * https://gnunn1.github.io/tilix-web/manual/vteconfig/ ================================================================================ [回到索引]
2017/10/30 22:48
|
||||||||||
![]() |
您可以查看帖子.
您不可發帖.
您不可回覆.
您不可編輯自己的帖子.
您不可刪除自己的帖子.
您不可發起投票調查.
您不可在投票調查中投票.
您不可上傳附件.
您不可不經審核直接發帖.