当前位置:网站首页>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
优点:无需编译。
边栏推荐
- 达晨与小米投的凌云光上市:市值153亿 为机器植入眼睛和大脑
- 2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
- MySQL入门尝鲜
- ClickHouse(03)ClickHouse怎么安装和部署
- Cookie
- .Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
- [difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
- HZOJ #236. Recursive implementation of combinatorial enumeration
- 线程池拒绝策略最佳实践
- JS中为什么基础数据类型可以调用方法
猜你喜欢
. Net ultimate productivity of efcore sub table sub database fully automated migration codefirst
自定义线程池拒绝策略
About the problem of APP flash back after appium starts the app - (solved)
Master formula. (used to calculate the time complexity of recursion.)
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
MATLAB中polarscatter函数使用
DHCP 动态主机设置协议 分析
《ASP.NET Core 6框架揭秘》样章[200页/5章]
Leetcode brush questions: binary tree 19 (merge binary tree)
[crawler] avoid script detection when using selenium
随机推荐
如何让electorn打开的新窗口在window任务栏上面
Leetcode brush questions: binary tree 19 (merge binary tree)
Practical example of propeller easydl: automatic scratch recognition of industrial parts
JNA学习笔记一:概念
[untitled]
[binary tree] delete points to form a forest
RecyclerView的数据刷新
Day21 multithreading
【学习笔记】线段树选做
Leetcode skimming: binary tree 21 (verifying binary search tree)
[learn wechat from 0] [00] Course Overview
[crawler] avoid script detection when using selenium
基于鲲鹏原生安全,打造安全可信的计算平台
2022 polymerization process test question simulation test question bank and online simulation test
Initialization script
Session
Leetcode skimming: binary tree 27 (delete nodes in the binary search tree)
JS中为什么基础数据类型可以调用方法
test
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst