오늘은 Hello World를 출력하는 시나몬 데스크릿을 만들어봤습니다. 그렇게 복잡하지는 않아요. 데스크릿은 2가지 핵심파일로 이뤄지는데, metadata.json파일과 desklet.js 파일입니다. 이 두개의 파일이 데스크릿을 만드는데 최소한으로 필요한 것들이죠.
metadata.json
{
"dangerous": false,
"description": "Hello World를 출력하는 데스크릿입니다!",
"prevent-decorations": false,
"uuid": "hello-world@jayks.ml",
"name": "Hello World!"
}
desklet.js
const Desklet = imports.ui.desklet;
const St = imports.gi.St;
// 생성자입니다.
function HelloWorld(metadata, desklet_id) {
this._init(metadata, desklet_id);
}
// HelloWorld 데스크릿의 프로토타입을 선언합니다.
HelloWorld.prototype = {
__proto__: Desklet.Desklet.prototype, // Desklet.Desklet을 프로토타입으로 합니다.
// 이 메서드는 초기화를 수행합니다.
_init: function(metadata, desklet_id) {
Desklet.Desklet.prototype._init.call(this, metadata, desklet_id);
this.setupUI();
},
// 이 메서드는 UI를 구성합니다.
setupUI: function() {
this.window = new St.Bin();
this.text = new St.Label();
this.text.set_text("Hello World!");
this.window.add_actor(this.text);
this.setContent(this.window);
}
};
// 이 함수가 데스크릿의 진입점입니다.
function main(metadata, desklet_id) {
return new HelloWorld(metadata, desklet_id);
}
이렇게 구성하면
이런 모양의 데스크릿을 만들 수 있습니다. 위 두 파일을 만드신 후에, ~/.local/share/cinnamon/desklets 디렉터리에 hello-world@jayks.ml 이라는 하위 디렉터리를 만들고 그 안에 다 넣어주시면 데스크릿 관리자에서 볼 수 있습니다.
이렇게요. 안타깝게도 UI는 일일히 코드를 쳐서 만들어야 합니다. 아직까지 디자이너 툴같은게 안나왔더군요. 아래는 데스크릿을 만들 때 참고할만한 API 레퍼런스입니다.
1. https://www.roojs.com/seed/gir-1.2-gtk-3.0/seed/St.Button.html
2. https://developer.gnome.org/st/stable/
'Anything' 카테고리의 다른 글
음, ... 리눅스에서 돌릴 수 있는 php 개발환경! (0) | 2017.07.23 |
---|---|
커스텀 액션 메뉴 어플릿 - 원클릭 동작 수행! (0) | 2017.07.23 |
어랏! 내 파일 어디갔지? - USB 펜드라이브로 파일이 제대로 복사가 되지 않는 현상 (0) | 2017.07.23 |
리눅스에 안드로이드 개발 환경 구축하기 (0) | 2017.07.22 |
GTK 3와 Webkit2.0로 리눅스 웹앱 만들기! (0) | 2017.07.22 |