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

优点:无需编译。
边栏推荐
- Awk of three swordsmen in text processing
- Practical example of propeller easydl: automatic scratch recognition of industrial parts
- Enterprise custom form engine solution (XII) -- experience code directory structure
- PACP学习笔记三:PCAP方法说明
- MySQL入门尝鲜
- leecode3. 无重复字符的最长子串
- 怎样重置火狐浏览器
- Go language learning notes - structure
- Layer pop-up layer closing problem
- Common text processing tools
猜你喜欢

Leetcode question brushing: binary tree 26 (insertion operation in binary search tree)

HZOJ #240. 图形打印四
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled]

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

2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation

Creation and assignment of graphic objects

【无标题】

Ogre入门尝鲜

Leetcode skimming: binary tree 21 (verifying binary search tree)

Leetcode brush questions: binary tree 19 (merge binary tree)
随机推荐
3D content generation based on nerf
2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
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
人均瑞数系列,瑞数 4 代 JS 逆向分析
AUTOCAD——大于180度的角度标注、CAD直径符号怎么输入?
RecyclerView的数据刷新
[learn microservice from 0] [01] what is microservice
DETR介绍
[difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
Leetcode skimming: binary tree 23 (mode in binary search tree)
Cookie
【无标题】
有什么类方法或是函数可以查看某个项目的Laravel版本的?
HZOJ #240. 图形打印四
About how appium closes apps (resolved)
Users, groups, and permissions
ICLR 2022 | pre training language model based on anti self attention mechanism
云检测2020:用于高分辨率遥感图像中云检测的自注意力生成对抗网络Self-Attentive Generative Adversarial Network for Cloud Detection
HZOJ #236. Recursive implementation of combinatorial enumeration
企业级自定义表单引擎解决方案(十二)--体验代码目录结构