当前位置:网站首页>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
优点:无需编译。
边栏推荐
- Sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
- ICLR 2022 | pre training language model based on anti self attention mechanism
- leecode3. 无重复字符的最长子串
- MySQL导入SQL文件及常用命令
- 通过Keil如何查看MCU的RAM与ROM使用情况
- Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
- 2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
- Find ID value MySQL in string
- Awk of three swordsmen in text processing
- Analysis of DHCP dynamic host setting protocol
猜你喜欢
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
HZOJ #240. Graphic printing IV
.Net下極限生產力之efcore分錶分庫全自動化遷移CodeFirst
博文推荐|Apache Pulsar 跨地域复制方案选型实践
TPG x AIDU|AI领军人才招募计划进行中!
How to continue after handling chain interruption / sub chain error removed from scheduling
自定义线程池拒绝策略
ISPRS2021/遥感影像云检测:一种地理信息驱动的方法和一种新的大规模遥感云/雪检测数据集
Cookie
About the problem of APP flash back after appium starts the app - (solved)
随机推荐
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
Day26 IP query items
达晨与小米投的凌云光上市:市值153亿 为机器植入眼睛和大脑
MySQL导入SQL文件及常用命令
MySQL master-slave replication
CMU15445 (Fall 2019) 之 Project#2 - Hash Table 详解
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
Ip2long and long2ip analysis
[learn microservice from 0] [01] what is microservice
2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
[binary tree] delete points to form a forest
飞桨EasyDL实操范例:工业零件划痕自动识别
日本政企员工喝醉丢失46万信息U盘,公开道歉又透露密码规则
@Resource和@Autowired的区别?
《开源圆桌派》第十一期“冰与火之歌”——如何平衡开源与安全间的天然矛盾?
2022 polymerization process test question simulation test question bank and online simulation test
Leetcode skimming: binary tree 21 (verifying binary search tree)
国泰君安证券开户怎么开的?开户安全吗?
ISPRS2021/遥感影像云检测:一种地理信息驱动的方法和一种新的大规模遥感云/雪检测数据集