当前位置:网站首页>Getting started with cinnamon applet
Getting started with cinnamon applet
2022-07-07 13:24:00 【Haitian Eagle】
file :
https://projects.linuxmint.com/reference/git/cinnamon-tutorials/write-applet.html
Cinnamon Applet route :
System :/usr/share/cinnamon/applets
user :~/.local/share/cinnamon/applets
1. Create folder [email protected]
2. newly build icon.png
3. newly build 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. newly build 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. Right click the taskbar - Problem solving - restart Cinnamon
advantage : No need to compile .
边栏推荐
猜你喜欢
人均瑞数系列,瑞数 4 代 JS 逆向分析
PACP学习笔记一:使用 PCAP 编程
Practical example of propeller easydl: automatic scratch recognition of industrial parts
10 张图打开 CPU 缓存一致性的大门
Introduce six open source protocols in detail (instructions for programmers)
Differences between MySQL storage engine MyISAM and InnoDB
[untitled]
ESP32 ① 编译环境
详细介绍六种开源协议(程序员须知)
QQ的药,腾讯的票
随机推荐
Simple and easy-to-use code specification
一文读懂数仓中的pg_stat
Scrapy教程经典实战【新概念英语】
解决缓存击穿问题
MongoDB 遇见 spark(进行整合)
基于鲲鹏原生安全,打造安全可信的计算平台
[etc.] what are the security objectives and implementation methods that cloud computing security expansion requires to focus on?
Coscon'22 community convening order is coming! Open the world, invite all communities to embrace open source and open a new world~
Final review notes of single chip microcomputer principle
QQ medicine, Tencent ticket
信号强度(RSSI)知识整理
The difference between cache and buffer
Go language learning notes - structure
RealBasicVSR测试图片、视频
[QNX Hypervisor 2.2用户手册]6.3.4 虚拟寄存器(guest_shm.h)
[learning notes] zkw segment tree
Day26 IP query items
My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
为租客提供帮助
PCAP学习笔记二:pcap4j源码笔记