当前位置:网站首页>Cinnamon Applet 入门
Cinnamon Applet 入门
2022-07-07 11:09:00 【海天鹰】
文档:
https://projects.linuxmint.com/reference/git/cinnamon-tutorials/write-applet.html
Cinnamon Applet 路径:
系统:/usr/share/cinnamon/applets
用户:~/.local/share/cinnamon/applets
1.创建文件夹 [email protected]
2.新建 icon.png
3.新建 metadata.json
{
"uuid": "[email protected]",
"name": "CMDU",
"description": "Uptime, CPU usage, memory usage, download bytes, upload bytes, download speed, upload speed",
"icon": "force-exit"
}4.新建 applet.js
const Applet = imports.ui.applet;
const Util = imports.misc.util;
const {GLib, Gio} = imports.gi;
function MyApplet(orientation, panel_height, instance_id) {
this._init(orientation, panel_height, instance_id);
}
MyApplet.prototype = {
__proto__: Applet.TextApplet.prototype,
_init: function(orientation, panel_height, instance_id) {
Applet.TextApplet.prototype._init.call(this, orientation, panel_height, instance_id);
this.set_applet_label("↑ 0KB/s\n↓ 0KB/s");
this.set_applet_tooltip(_("Uptime:\nCPU:\nMem:\nUp:\nDown:"));
//https://gjs.guide/guides/gjs/asynchronous-programming.html
GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
var date = new Date();
var s = date.getFullYear() + "/" + (date.getMonth()+1) + "/" + date.getDate() + "\n" + date.getHours() + ":" + date.getMinutes()+ ":" + date.getSeconds();
this.set_applet_label(s);
this.set_applet_tooltip(_("Uptime: " + this.uptime() + "\nCPU:\nMem:\nUp:\nDown:"));
return true; // loop
});
},
on_applet_clicked: function() {
Util.spawnCommandLine("gnome-system-monitor");
}
};
function main(metadata, orientation, panel_height, instance_id) {
return new MyApplet(orientation, panel_height, instance_id);
}5.任务栏右键 - 疑难解决 - 重启 Cinnamon

优点:无需编译。
边栏推荐
- ClickHouse(03)ClickHouse怎么安装和部署
- HZOJ #235. Recursive implementation of exponential enumeration
- MySQL importing SQL files and common commands
- Grep of three swordsmen in text processing
- 详细介绍六种开源协议(程序员须知)
- 关于 appium 启动 app 后闪退的问题 - (已解决)
- [difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
- 达晨与小米投的凌云光上市:市值153亿 为机器植入眼睛和大脑
- - Oui. Migration entièrement automatisée de la Sous - base de données des tableaux d'effets sous net
- Initialization script
猜你喜欢

HZOJ #240. 图形打印四

关于 appium 启动 app 后闪退的问题 - (已解决)

.Net下極限生產力之efcore分錶分庫全自動化遷移CodeFirst

TPG x AIDU|AI领军人才招募计划进行中!

Leetcode brush questions: binary tree 19 (merge binary tree)

ICLR 2022 | pre training language model based on anti self attention mechanism

2022 polymerization process test question simulation test question bank and online simulation test

ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics

Awk of three swordsmen in text processing

Practical example of propeller easydl: automatic scratch recognition of industrial parts
随机推荐
Leetcode brush question: binary tree 24 (the nearest common ancestor of binary tree)
HZOJ #236. Recursive implementation of combinatorial enumeration
About how appium closes apps (resolved)
[learn microservice from 0] [01] what is microservice
leecode3. 无重复字符的最长子串
高瓴投的澳斯康生物冲刺科创板:年营收4.5亿 丢掉与康希诺合作
免费手机号码归属地API查询接口
2022-07-07 Daily: Ian Goodfellow, the inventor of Gan, officially joined deepmind
Conversion from non partitioned table to partitioned table and precautions
Shortcut key of Bash
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
What are the benefits of ip2long?
【学习笔记】线段树选做
[untitled]
学习突围2 - 关于高效学习的方法
自定义线程池拒绝策略
Leetcode skimming: binary tree 21 (verifying binary search tree)
Day21 multithreading
COSCon'22 社区召集令来啦!Open the World,邀请所有社区一起拥抱开源,打开新世界~
Cookie and session comparison