当前位置:网站首页>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 .
边栏推荐
猜你喜欢
![Scripy tutorial classic practice [New Concept English]](/img/bc/f1ef8b6de6bfb6afcdfb0d45541c72.png)
Scripy tutorial classic practice [New Concept English]

Awk of three swordsmen in text processing

DHCP 动态主机设置协议 分析

将数学公式在el-table里面展示出来

共创软硬件协同生态:Graphcore IPU与百度飞桨的“联合提交”亮相MLPerf

Ogre入门尝鲜

记一次 .NET 某新能源系统 线程疯涨 分析
![[dark horse morning post] Huawei refutes rumors about](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours

Scrapy教程经典实战【新概念英语】

Write it down once Net a new energy system thread surge analysis
随机推荐
Practical case: using MYCAT to realize read-write separation of MySQL
LIS 最长上升子序列问题(动态规划、贪心+二分)
Pay close attention to the work of safety production and make every effort to ensure the safety of people's lives and property
[untitled]
Why can basic data types call methods in JS
API query interface for free mobile phone number ownership
分布式事务解决方案
Introduction and basic use of stored procedures
How to reset Google browser? Google Chrome restore default settings?
MongoDB内部的存储原理
RecyclerView的数据刷新
ORACLE进阶(五)SCHEMA解惑
JS determines whether an object is empty
飞桨EasyDL实操范例:工业零件划痕自动识别
PCAP学习笔记二:pcap4j源码笔记
DrawerLayout禁止侧滑显示
leecode3. 无重复字符的最长子串
自定义线程池拒绝策略
Read PG in data warehouse in one article_ stat
PAcP learning note 1: programming with pcap