2015-04-23 33 views
1

嗨,正在尋找一段時間,我怎麼可以添加一個應用程序或小部件,顯示我的腳本或命令的輸出,如「主機名--fqdn」在我的侏儒面板或我的桌面背景...... conky做到這一點,但我認爲這對於一個簡單的shell輸出giplet來說只適用於ip,並且只適用於gnome面板,並且沒有用於debian wheezy的軟件包。在Gnome面板或我的桌面背景上顯示我的主機名/ IP的簡單方法?

我已經在2000年左右在一個更大的區域和一個正在運行的應用程序中顯示很多,但如果這個應用程序停機,那麼正常的桌面是最好的:)所以在這種情況下,最好顯示一個主機名/ IP地址工程。

回答

0

你可以用GNOME Shell擴展來解決這個問題。

我寫了一個簡單的擴展,可能會幫助你。

extension.js文件:

const Clutter = imports.gi.Clutter; 
const Main = imports.ui.main; 
const GLib = imports.gi.GLib; 

const COMMAND = "hostname --fqdn"; 
const FONT_SIZE = 48; 
let stage_bg_color = Clutter.Color.get_static(Clutter.StaticColor.CHOCOLATE_DARK); 

let myactor = null; 

function run_command() { 
    let output = ""; 
    try { 
     output = GLib.spawn_command_line_sync(COMMAND, null, null, null, null); 
    } catch(e) { 
     throw e; 
    } 

    return output[1] + ""; 
} 

function init() { 
    let myactor = new Clutter.Text(); 
    myactor.set_font_name("Sans " + FONT_SIZE); 
    myactor.set_position(400, 400); 
    myactor.set_background_color(stage_bg_color); 

    myactor.set_text(run_command()); 

    let n_children = Main.layoutManager._backgroundGroup.get_n_children(); 
    Main.layoutManager._backgroundGroup.insert_child_at_index(myactor, n_children); 
} 

function enable() { 
} 

function disable() { 
} 

metadata.js文件(注意外殼版本):

{"shell-version": ["3.14.4"], "uuid": "[email protected]", "name": "Command wallpaper", "description": "It shows the output of a command on the wallpaper"} 

保存內外夾中的文件$ HOME/.local/share/gnome-shell/extensions/。要啓用它,請使用gnome-shell-extension-prefs

或者您可以從here下載它。

相關問題