当前位置:网站首页>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

优点:无需编译。
边栏推荐
- JNA学习笔记一:概念
- 《ASP.NET Core 6框架揭秘》样章[200页/5章]
- 谷歌浏览器如何重置?谷歌浏览器恢复默认设置?
- @What is the difference between resource and @autowired?
- Leetcode skimming: binary tree 23 (mode in binary search tree)
- 货物摆放问题
- Session
- How to continue after handling chain interruption / sub chain error removed from scheduling
- How to reset Firefox browser
- Adopt a cow to sprint A shares: it plans to raise 1.85 billion yuan, and Xu Xiaobo holds nearly 40%
猜你喜欢

“新红旗杯”桌面应用创意大赛2022

Four functions of opencv

为租客提供帮助

Cookie

MySQL master-slave replication

Image pixel read / write operation

飞桨EasyDL实操范例:工业零件划痕自动识别

Lingyunguang of Dachen and Xiaomi investment is listed: the market value is 15.3 billion, and the machine is implanted into the eyes and brain

Session

Differences between MySQL storage engine MyISAM and InnoDB
随机推荐
Image pixel read / write operation
@What is the difference between resource and @autowired?
测试下摘要
Coscon'22 community convening order is coming! Open the world, invite all communities to embrace open source and open a new world~
【学习笔记】zkw 线段树
How to continue after handling chain interruption / sub chain error removed from scheduling
Leetcode skimming: binary tree 21 (verifying binary search tree)
3D content generation based on nerf
博文推荐|Apache Pulsar 跨地域复制方案选型实践
How does MySQL create, delete, and view indexes?
关于 appium 启动 app 后闪退的问题 - (已解决)
RecyclerView的数据刷新
MySQL importing SQL files and common commands
红杉中国完成新一期90亿美元基金募集
Star Enterprise Purdue technology layoffs: Tencent Sequoia was a shareholder who raised more than 1billion
Differences between MySQL storage engine MyISAM and InnoDB
环境配置篇
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
@Resource和@Autowired的区别?
PACP学习笔记三:PCAP方法说明