当前位置:网站首页>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
优点:无需编译。
边栏推荐
- HZOJ #236. 递归实现组合型枚举
- 智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
- Awk of three swordsmen in text processing
- Practical example of propeller easydl: automatic scratch recognition of industrial parts
- 通过Keil如何查看MCU的RAM与ROM使用情况
- Sequoia China completed the new phase of $9billion fund raising
- HZOJ #235. Recursive implementation of exponential enumeration
- [learn wechat from 0] [00] Course Overview
- 明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
- Sed of three swordsmen in text processing
猜你喜欢
About how appium closes apps (resolved)
为租客提供帮助
DHCP 动态主机设置协议 分析
Adopt a cow to sprint A shares: it plans to raise 1.85 billion yuan, and Xu Xiaobo holds nearly 40%
滑轨步进电机调试(全国海洋航行器大赛)(STM32主控)
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
About the problem of APP flash back after appium starts the app - (solved)
明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
PACP学习笔记一:使用 PCAP 编程
Blog recommendation | Apache pulsar cross regional replication scheme selection practice
随机推荐
博文推荐|Apache Pulsar 跨地域复制方案选型实践
【Presto Profile系列】Timeline使用
[untitled]
Star Enterprise Purdue technology layoffs: Tencent Sequoia was a shareholder who raised more than 1billion
初学XML
Talk about four cluster schemes of redis cache, and their advantages and disadvantages
Smart cloud health listed: with a market value of HK $15billion, SIG Jingwei and Jingxin fund are shareholders
【无标题】
The difference between cache and buffer
. Net ultimate productivity of efcore sub table sub database fully automated migration codefirst
企业级自定义表单引擎解决方案(十二)--体验代码目录结构
[untitled]
What kind of methods or functions can you view the laravel version of a project?
[learn microservice from 0] [01] what is microservice
About the problem of APP flash back after appium starts the app - (solved)
Differences between MySQL storage engine MyISAM and InnoDB
Blog recommendation | Apache pulsar cross regional replication scheme selection practice
regular expression
[difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
滑轨步进电机调试(全国海洋航行器大赛)(STM32主控)