文件操作 - extension.js
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/gnome-shell/extensions/top-icons@gnome-shell-extensions.gcampax.github.com/extension.js
编辑文件内容
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- const Clutter = imports.gi.Clutter; const GObject = imports.gi.GObject; const Shell = imports.gi.Shell; const St = imports.gi.St; const Main = imports.ui.main; const PanelMenu = imports.ui.panelMenu; const System = imports.system; let icons = []; let sysTray = null; const PANEL_ICON_SIZE = 16; const STANDARD_TRAY_ICON_IMPLEMENTATIONS = [ 'bluetooth-applet', 'gnome-sound-applet', 'nm-applet', 'gnome-power-manager', 'keyboard', 'a11y-keyboard', 'kbd-scrolllock', 'kbd-numlock', 'kbd-capslock', 'ibus-ui-gtk' ]; function init() { } function enable() { createTray(); } function onTrayIconAdded(o, icon) { let wmClass = icon.wm_class ? icon.wm_class.toLowerCase() : ''; if (STANDARD_TRAY_ICON_IMPLEMENTATIONS.includes(wmClass)) return; let button = new PanelMenu.Button(0.5, null, true); let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; let iconSize = PANEL_ICON_SIZE * scaleFactor; icon.set_size(iconSize, iconSize); icon.set_x_align(Clutter.ActorAlign.CENTER); icon.set_y_align(Clutter.ActorAlign.CENTER); icon.bind_property('title', button.actor, 'accessible-name', GObject.BindingFlags.SYNC_CREATE); let iconBin = new St.Widget({ layout_manager: new Clutter.BinLayout(), }); iconBin.add_actor(icon); button.actor.add_actor(iconBin); icons.push(icon); button.actor.connect('button-release-event', function(actor, event) { icon.click(event); }); button.actor.connect('key-press-event', function(actor, event) { icon.click(event); }); icon.connect('destroy', function() { button.destroy(); }); let role = wmClass || `${icon}`; Main.panel.addToStatusArea(role, button); } function onTrayIconRemoved(o, icon) { let parent = icon.get_parent(); parent.destroy(); icons.splice(icons.indexOf(icon), 1); } function createTray() { sysTray = new Shell.TrayManager(); sysTray.connect('tray-icon-added', onTrayIconAdded); sysTray.connect('tray-icon-removed', onTrayIconRemoved); sysTray.manage_screen(global.screen, Main.panel.actor); } function destroyTray() { icons.forEach(icon => { icon.get_parent().destroy(); }); icons = []; sysTray = null; System.gc(); // force finalizing tray to unmanage screen } function disable() { destroyTray(); }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件