今月の19日ぐらいにUbuntu 17.
GNOME ShellとJavaScript
今回のリリースはGNOME Shellを抜きにしても,
さてそんなGNOME Shellについて。これまで採用してきたUnityに対する最大のアドバンテージはその
GNOME Shellの拡張機能はJavaScriptとCSSで構成されています。つまりウェブ開発の経験があれば比較的かんたんに拡張機能を作成できるのです。実はGNOME Shell本体も,
ちなみにGNOME ShellではJavaScriptエンジンとして,
たとえばGNOME Shell上で
GNOME Shell Extension
さっそくGNOME Shellの拡張機能を作ってみましょう。今回はまだ開発版であるUbuntu 17.
GNOME Shellには拡張機能の管理コマンドであるgnome-shell-extension-tool
」
適当なディレクトリで--create-extension
」
$ gnome-shell-extension-tool --create-extension Name should be a very short (ideally descriptive) string. Examples are: "Click To Focus", "Adblock", "Shell Window Shrinker". Name: Sample Description is a single-sentence explanation of what your extension does. Examples are: "Make windows visible on click", "Block advertisement popups" "Animate windows shrinking on minimize" Description: Sample Extension for Recipe Uuid is a globally-unique identifier for your extension. This should be in the format of an email address (foo.bar@extensions.example.com), but need not be an actual email address, though it's a good idea to base the uuid on your email address. For example, if your email address is janedoe@example.com, you might use an extension title clicktofocus@janedoe.example.com. Uuid [Sample@ubuntu-ax2]: sample@mty.shibata.gmail.com Created extension in '/home/shibata/.local/share/gnome-shell/extensions/sample@mty.shibata.gmail.com' This tool has been deprecated, use 'gio open' instead. See 'gio help open' for more info.
決めなければならない項目は次の3つです。
- 名前
(Name) - 概要
(Description) - UUID
名前と概要は自由に設定してください。UUIDはユニークなIDをつけますが,
設定が完了するとエディターが起動し,extension.
」
- ※1
- 「
xdg-open ファイル名
」で起動するのですが, xdg-open
から呼び出しているgvfs-open
がdeprecatedなために,上記のような警告メッセージが出ています。将来的に gio open
コマンドが使われるようになるはずです。
- extension.
js - metadata.
json - stylesheet.
css
「extension.
」metadata.
」stylesheet.
」
作成されたファイルはユーザー固有の拡張機能ディレクトリ~/.local/
)
$ ls -la ~/.local/share/gnome-shell/extensions/sample@mty.shibata.gmail.com/ 合計 20 drwxrwxr-x 2 shibata shibata 4096 10月 7 20:32 . drwxrwxr-x 3 shibata shibata 4096 10月 7 20:32 .. -rw-rw-r-- 1 shibata shibata 1468 10月 7 20:32 extension.js -rw-rw-r-- 1 shibata shibata 133 10月 7 20:32 metadata.json -rw-rw-r-- 1 shibata shibata 172 10月 7 20:32 stylesheet.css $ cat ~/.local/share/gnome-shell/extensions/sample@mty.shibata.gmail.com/metadata.json {"name": "Sample", "description": "Sample Extension for Recipe", "uuid": "sample@mty.shibata.gmail.com", "shell-version": ["3.26.1"]} $ cat ~/.local/share/gnome-shell/extensions/sample@mty.shibata.gmail.com/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の拡張機能をインストールしたときは,/usr/
」
サンプル拡張機能の有効化
拡張機能をインストールしただけでは機能は有効になっていません。第490回でも説明しているように,
余計なものをインストールしたくないのであれば,gnome-shell-extension-prefs
」
このコマンドはインストール済みの拡張機能をリストアップして個別に有効化・
よって有効化・
$ gsettings get org.gnome.shell enabled-extensions ['sample@mty.shibata.gmail.com']
環境によっては有効化前もしくは有効化後にGNOME Shellを再読込する必要があるようです。
サンプルの拡張機能が有効化されたら,