walNUT icon indicating copy to clipboard operation
walNUT copied to clipboard

A Gnome Shell Extension for NUT (Network UPS Tools)

walNUT

Daniele Pezzini [email protected] v0.3, July 2015 :numbered: :imagesdir: img :icons: :iconsdir: ../ad/icons :badges: :disable-javascript: :linkcss: :stylesdir: ../ad/style :stylesheet: custom.css :max-width: 1024px

// Xrefs :installation: installation :first-execution: first-execution :panel-icon: panel-icon :panel-menu: panel-menu :device-list: device-list :device-model: device-model :device-status: device-status :device-alarm: device-alarm :data-table: data-table :raw-vars: raw-vars :device-commands: device-commands :control-buttons: control-buttons :credentials-box: credentials-box :find-new-devices: find-new-devices :delete-devices: delete-devices :device-credentials: device-credentials :credentials-dialog: credentials-dialog :preferences: preferences :help: help

// Override xrefs and images' directory for GitHub's README.adoc ifdef::env-github[]

:imagesdir: help/C/img

:installation: 1-installation :first-execution: 2-first-execution :panel-icon: 3-panel-iconlabel :panel-menu: 4-panel-menu :device-list: 41-device-list :device-model: 42-device-model :device-status: 43-device-status :device-alarm: 44-device-alarm :data-table: 45-data-table :raw-vars: 46-raw-vars :device-commands: 47-devices-commands :control-buttons: 48-control-buttons :credentials-box: 49-credentials-box :find-new-devices: 410-find-new-devicesfind-new-devices-box :delete-devices: 411-delete-devicesdelete-devices-box :device-credentials: 5-device-credentials :credentials-dialog: 51-credentials-dialog :preferences: 6-preferences :help: 8-help

endif::env-github[]

[float] What is it?

walNUT is nothing more than a Gnome Shell extension providing a graphical interface to NUT (http://www.networkupstools.org[Network UPS Tools]). It provides you a handy <<{panel-menu},panel menu>> and <<{panel-icon},icon>> to monitor your devices and execute NUT's instant <<{device-commands},commands>>.

Before <<{installation},you start>>, you need an already up and running NUT on the machine that will monitor the UPSes (it's not necessary to have NUT installed on the same computer you want walNUT to run in, provided that it isn't the one that's in charge of communicating with the UPS): having said that, if everything goes well with http://www.networkupstools.org/docs/man/upsc.html[upsc], http://www.networkupstools.org/docs/man/upsrw.html[upsrw] and http://www.networkupstools.org/docs/man/upscmd.html[upscmd], chances are high that walNUT will work right <<{first-execution},out of the box>>.

[NOTE]

Since the GJS implementation of NUT's net protocol doesn't support yet TLS, if you need it, you can get it using the walNUT version that relies on upsc, upsrw and upscmd:

  • https://github.com/zykh/walNUT/tree/tls-through-nut ====

[[installation]] Installation

You can install this extension for your user by executing:


cd ~/.local/share/gnome-shell/extensions git clone --depth 1 https://github.com/zykh/walNUT.git walnut@networkupstools glib-compile-schemas walnut@networkupstools/schemas/

After the installation you'll need to restart Gnome Shell:

  • ALT+F2 to open the command prompt
  • Enter +r+ to restart Gnome Shell

Then you can enable the extension through https://live.gnome.org/GnomeTweakTool[Gnome Tweak Tool] (Shell Extensions -> walNUT -> On) or through https://extensions.gnome.org/local/

[IMPORTANT]

Users of previous versions of walNUT, when upgrading, must always recompile the schema:


cd ~/.local/share/gnome-shell/extensions/walnut@networkupstools git fetch git merge glib-compile-schemas schemas/

====

[[first-execution]] First execution

Once you've <<{installation},installed>> walNUT, when it's executed for the first time, or every time its device list is empty, it'll try and search automatically for new devices at localhost:3493. + So, for most installations, it should have already found your devices. If not, you have to add them through the <<{find-new-devices},find new devices box>>.

It's important that you understand how walNUT communicates with you and how you can customize it: please read <<{panel-icon},panel icon/label>>, <<{panel-menu},panel menu>> and <<{preferences},preferences>> sections.

[[panel-icon]] Panel icon/label

walNUT's icon and label are customizable through the <<{preferences},preferences>>. + Here is explained how they behave.

[cols="1^.^,9.^",frame="topbot",grid="rows",align="center",options="autowidth"] |==== |image:icons.png["Panel Icon"] |The panel icon standardly displays only battery charge [A], but it can display also device load [B], if available. + In that case the `seed' of the walnut will be split up in two pieces: the leftmost [1] will display battery charge, the rightmost [2] load level.

									 In case you set also to _Display load in panel icon_ in the <<{preferences},preferences>> _and_ battery charge is not available, the left side of the `seed' [*3*] will be full and transparent.

|image:icon_ol_ob.png["Panel Icon - Online/On Battery + Charged/Charging"] |The panel icon displays also the state of the line: if the device is on line (mains is not absent, +ups.status+: +OL+) there will be a small lightning [C] at the right of the nut that wont be displayed if the device is on battery [D]. + That lightning will show also if the device is charged or not: if battery charge is 100% or if battery charge is not available and the device isn't telling us it's charging or discharging (+ups.status+: +CHRG+/+DISCHRG+) we'll assume it's charged and the lightning will be transparent [E], otherwise it'll be at full opacity [F]. |image:icon_caution.png["Panel Icon - Caution"] |For other status (+ups.status+: +BYPASS+, +TRIM+, ..) or if an alarm arises (+ups.status+: +ALARM+ + +ups.alarm+) there will be an exclamation mark on the right top angle of the nut. |image:icon_ghost.png["Panel Icon - Ghost"] |If battery charge is not available or if also Display load in panel icon option is selected in the <<{preferences},preferences>> and both device load and battery charge aren't available the icon will be a full transparent nut. |image:icon_error.png["Panel Icon - Error"] |That's the icon displayed in case of errors. |image:icon_labels.png["Panel Labels"] |walNUT can also display a label, at the right of the icon in the panel, with battery charge [G], device load [H] or both [I], if available. |====

[NOTE]

The icon shows charge/load through 3 bars:

[cols="1^.^,2.^,7.^",frame="topbot",grid="rows",align="center",options="header,autowidth"] |==== |Icon |Bars |Meaning |image:icon_3bars.png["3 bars for charge/load"] |3 bars |More than 75% |image:icon_2bars.png["2 bars for charge/load"] |2 bars |Between 50% and 75% |image:icon_1bar.png["1 bar for charge/load"] |1 bar |Between 25% and 50% |image:icon_0bars.png["No bars for charge/load"] |no bars |Less than 25% |====

[[panel-menu]] Panel menu

Here's a quick overview of the panel menu. + Standardly the menu looks like this:

image::menustd.png["Panel Menu", align = "center"]

With all the available options set:

image::menu.png["Panel Menu - Complete", align = "center"]

The menu can be split up in various sections:

A. <<{device-list},Device List>> B. <<{device-model},Device Model>> C. <<{device-status},Device Status>> D. <<{device-alarm},Device Alarm>> E. <<{data-table},Data Table>> F. <<{raw-vars},Raw Vars>> G. <<{device-commands},Device Commands>> H. Box for control buttons' functions

  • <<{credentials-box},Device credentials box>>
  • <<{find-new-devices},Find new devices box>>
  • <<{delete-devices},Delete device box>> I. <<{control-buttons},Control Buttons>>

In case of errors, the menu appears like this:

image::menuerr.png["Panel Menu - Error", align="center"]

Where the device list [A] is visible or not, depending on the type of error [L].

[[device-list]] Device list


image::devicelist.png["Device List", align = "center"]

Devices are listed in _hostname:port_ alphabetical order and then alphabetically by their name.

NOTE: Every device stored in _walNUT_'s own list will be prompted for availability *every time* you change some option or Gnome Shell is refreshed (e.g. return from screen block ..and so on) or 15 minutes after the last update.

image::devicelist_open.png["Device List opened", align = "center"]

Not available devices are signaled with a *(N/A)* [*A*] at their right.
You can choose either to display or not not available devices in the <<{preferences},preferences>>.


[[device-model]]
Device model

image::devicemodel.png["Device Model", align = "center"]

If available both device manufacturer and device model will be shown here.

TIP: If your device isn't providing one of device manufacturer/model or both or if you want a more appealing label, you can override one of them or both in http://www.networkupstools.org/docs/man/ups.conf.html[ups.conf].

You can choose whether to display or not this information changing its option in the <<{preferences},preferences>>.

[[device-status]] Device status


image::devicestatus.png["Device Status", align = "center"]

Device status will show: line status [*A*] (online/on battery), and then, on the second row, every status reported by the device [*B*] (bypass, trim, ..).


[[device-alarm]]
Device alarm
~~~~~~~~~~~~

image::devicealarm.png["Device Alarm", align = "center"]

If an alarm is set (+ups.status+: +ALARM+ and +ups.alarm+) it'll be shown here.

NOTE: An alarm will be signaled also through an `exclamation mark' on the <<{panel-icon},panel icon>>.


[[data-table]]
Data table
~~~~~~~~~~

image::datatable.png["Data Table", align = "center"]

If available, [*A*] battery charge, [*B*] device load, [*C*] backup time and [*D*] device temperature will be shown here. +
Battery icon [*1*] will display actual charge through the number of horizontal bars (as the ones of <<{panel-icon},panel icon>>).

You can choose whether to display or not these data changing their options in the <<{preferences},preferences>>.


[[raw-vars]]
Raw vars
~~~~~~~~

image::raw.png["Raw Vars", align = "center"]

If you want a deep dive in all the variables available for a device you have to select the _Display raw data_ option in the <<{preferences},preferences>>: raw vars will be displayed in a scrollable submenu.

If a variable is settable, a *`+`* will be shown at the left of its name: clicking on this var will open a new box where you'll be able to change its value.

image::setvars.png["Settable vars", align = "center"]

Clicking again on the variable will close the box: the changes done won't be discarded so that you can go back and edit the var starting from where you left.

NOTE: In order to set a variable you have to provide a <<{device-credentials},valid username and password>> (_as set in http://www.networkupstools.org/docs/man/upsd.users.html[upsd.user] configuration file_).

If the variable is of type `++STRING++' you can insert a value in the text box [*A*]: if you then click on the `Set' button [*B*] the provided value will be sent to the driver.
If you click on the `Undo and close' button [*C*] the provided value will be discarded and the box closed.

image::setvars_string.png["Settable vars - STRING", align = "center"]

[NOTE]
====
In case the provided value is longer than the acceptable length, you'll be notified of the error and you won't be able to click on the `Set' button [*B*].

image::setvars_string_error.png["Settable vars - STRING, error", align = "center"]
====

If the variable is of type `++ENUM++', the enumerated values will be listed in the box: if you click on one of them [*D*] the corresponding value will be sent to the driver.
Also the actually chosen option will be shown, but it won't be clickable [*E*].

image::setvars_enums.png["Settable vars - ENUM", align = "center"]

If the variable is of type `++RANGE++', the available ranges will be shown in the box and you'll then be able to choose the one you need to use.

image::setvars_ranges.png["Settable vars - RANGE, more than one", align = "center"]

Once a range is chosen (provided that more than one range is available) [*F*], its limits [*G*, *H*] will be displayed at the right and left of the actual value [*I*].

image::setvars_ranges_set.png["Settable vars - RANGE, edit", align = "center"]

You can then change the value either dragging the slider [*J*], or scrolling the mouse wheel over it or you can choose to increase or decrease the value by one unit at a time clicking on the -/+ buttons [*K*, *L*].

image::setvars_ranges_btn.png["Settable vars - RANGE, buttons", align = "center"]

If you click on the `Set' button [*M*] the provided value will be sent to the driver.
If you click on the `Undo and close' button [*N*] the provided value will be discarded and the box closed.

In case only one range is available, only its limits will be shown.

image::setvars_range.png["Settable vars - RANGE", align = "center"]


[[device-commands]]
Device commands

image::cmd.png["Device Commands", align = "center"]

If you want to execute NUT's instant commands through walNUT you have to set the Display device commands option in the <<{preferences},preferences>>.

You can also pass to the command some extra data filling, before you click on the command, the entry [A] that will appear next to the device commands submenu when it is opened.

image::cmd_extra.png["Device Commands - Extra data", align = "center"]

Note that, when you click on a command, it'll be executed.

[TIP]

walNUT standardly displays also a localized description of the commands [B], but if you think that it steals too much space you can set not to display it [C] in the <<{preferences},preferences>>.

image::cmd_sm_vs.png["Device Commands - Sub Menu, with or w/o description", align = "center"]

Once a command has been executed, you'll be notified whether it has been successfully sent to the driver [D] or not [E].

image::cmd_notify.png["Device Commands - Notify", align = "center"]

[[control-buttons]] Control buttons


image::btns.png["Control Buttons", align = "center"]

At the bottom of the <<{panel-menu},panel menu>> there's a handful of control buttons, some of which will open their own box [*A*] just before the controls row [*B*].

image::btns_box.png["Control Buttons + Control Box", align = "center"]

The buttons will show:

1. <<{preferences},Preferences>>
2. <<{credentials-box},Device crendetials box>>
3. <<{find-new-devices},Find new devices box>>
4. <<{delete-devices},Delete devices box>>
5. <<{help},Help>>


[[credentials-box]]
Credentials box

image::credbox.png["Credentials Box", align = "center"]

Clicking on the `credentials' button [A] the credentials box [B] will open. This box is used to store username and password for devices so that you don't have to be prompted for them every time you execute a command.

NOTE: If you want to delete username, password or both (e.g. so that you will be prompted for them from now on), you have to save them empty.

If you click on the [1] undo and close' button any change you made to user/password before clicking on [*2*] save' button will be discarded.

TIP: Standardly the password is hidden, but if you want, you can choose not to hide it in the <<{preferences},preferences>>.

[[find-new-devices]] Find new devices/find new devices box


image::addbox.png["Find new devices Box", align = "center"]

In order to find new devices, once you clicked on the [*A*] `find' button, you have to insert the devices' hostname [*1*] and port [*2*] and then click on the [*B*] `start search' button.

NOTE: If the hostname isn't given it'll be _localhost_, while port, if not given, will fall back to _3493_.

You will be notified either if new devices are found [*C*] or not [*D*].

image::add_notify.png["Find new devices - Notify", align = "center"]


[[delete-devices]]
Delete devices/delete devices box
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

image::delbox.png["Delete device Box", align = "center"]

If you want to delete a device, first you have to select it from the <<{device-list},device list>>, and then you have to click on the [*A*] `delete' button. +
A new box [*B*] will appear asking you if you really want to delete it [*1*] or not [*2*].

NOTE: If you want to delete a device that's not currently available, check first to have enabled the _Display not available devices_ option in the <<{preferences},preferences>>.


[[device-credentials]]
Device credentials
------------------

If you want to execute a device's <<{device-commands},instant commands>> or to set a <<{raw-vars},settable variable>>, you have to provide a valid username and password (_as set in http://www.networkupstools.org/docs/man/upsd.users.html[upsd.user] configuration file_).
You can either save them through the <<{credentials-box},credentials box>> or insert them in the <<{credentials-dialog},credentials dialog>> *every time* you execute a command.

NOTE: If the saved user and password prove to be wrong you will be prompted for them with a <<{credentials-dialog},credential dialog>> when you try to execute a command.

IMPORTANT: If you choose to save the user and password and then use them for both instant commands and settable vars, be sure that the provided username has the appropriate options set for both of them in http://www.networkupstools.org/docs/man/upsd.users.html[upsd.user] configuration file (e.g. +actions = set+ and +instcmds = all+).


[[credentials-dialog]]
Credentials dialog
~~~~~~~~~~~~~~~~~~

image::creddialog.png["Credentials dialog", align = "center"]

The credentials dialog will prompt you to insert a valid username or password either if they've not been saved through the <<{credentials-box},credentials box>> or if they proved to be wrong [*A*].

image::creddialog_err.png["Credentials dialog - error", align = "center"]

NOTE: The [*B*] `execute' button will be sensitive only if both username and password are not empty.

CAUTION: Once you have inserted the username and the password, when you click on the [*B*] `execute' button, the command will be sent to the driver.


[[preferences]]
Preferences
-----------

To fine tune _walNUT_ to suit your needs you may want to change some options.

image::prefbtn.png["Preferences Button", align = "center"]

You can access the preferences from the [*A*] preferences button in the <<{panel-menu},panel menu>>.

A new window will open, where you can set the various options.

image::pref.png["Preferences - General/Panel", align = "center"]

'General/Panel' tab - extension general options and <<{panel-icon},panel icon/label>> options:

[caption=""]
.Available Options
[cols="5>s,20<,75<",frame="topbot",grid="rows",align="center",options="header,autowidth"]
|====
|#	|Option				|Description
3+<e|General options
|1	|Seconds before next update	|The seconds after _walNUT_ updates the data from the device. (_default: 15_)
|2	|Temperature unit		|The unit (Centigrade or Fahrenheit) _walNUT_ should display the temperature in. (_default: Centigrade_)
3+<e|Panel options
|3	|Display load in the icon	|Whether the device load should be displayed in the panel icon or not. (_default: OFF_)
|4	|Display load in the label	|Whether the device load should be displayed in the panel label or not. (_default: OFF_)
|5	|Display charge in the label	|Whether the battery charge should be displayed in the panel label or not. (_default: OFF_)
|====

image::pref_menu.png["Preferences - Menu", align = "center"]

'Menu' tab - <<{panel-menu},panel menu>> options:

[caption=""]
.Available Options
[cols="5>s,20<,75<",frame="topbot",grid="rows",align="center",options="header,autowidth"]
|====
|#	|Option					|Description
|1	|Display not available devices		|Display also not available devices in the submenu in the panel menu (chosen device will be always displayed, also if not available, in spite of this option). (_default: OFF_)
|2	|Display device model			|Show also device model (`manufacturer - model'), if available, in the panel menu. (_default: ON_)
|3	|Display battery charge			|Show also battery charge, if available, in the panel menu. (_default: ON_)
|4	|Display load level			|Show also load level, if available, in the panel menu. (_default: ON_)
|5	|Display backup time			|Show also backup time, if available, in the panel menu. (_default: ON_)
|6	|Display device temperature		|Show also device temperature, if available, in the panel menu. (_default: ON_)
|7	|Display raw data			|Show also raw data in a submenu. (_default: OFF_)
|8	|Display device commands		|Display available device commands. You'll need upsd user and password to execute them. (_default: OFF_)
|9	|Display description of device commands	|Display also a localized description of available device commands in the submenu. (_default: ON_)
|10	|Hide password at credentials box	|Whether the password at credentials box should be hidden or not. (_default: ON_)
|====


[[help]]
Help
----

If this manual doesn't answer your questions or for every problem you may encounter, you can find some help at NUT's list:

- *NUT Users* - http://lists.alioth.debian.org/mailman/listinfo/nut-upsuser

If you want to help, you are welcomed in NUT's list and NUT's developers list:

- *NUT Developers* - http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev


Translators
~~~~~~~~~~~

A guide to translate extensions can be found in Gnome Shell extensions' https://wiki.gnome.org/Projects/GnomeShell/Extensions/FAQ/CreatingExtensions[FAQ].

_walNUT_'s documentation is done in http://www.methods.co.nz/asciidoc/[AsciiDoc] and then processed either to the html version and to the http://projectmallard.org/[Mallard] version for http://projects.gnome.org/yelp/[Yelp].

The help files must be put in the extension's help subdir, creating a directory named after the desired locale's language code (e.g. en, it, ..) or, for country-specific locales, language code and country code (e.g. pt_BR, pt_PT).

The html version must be compiled with:

----
asciidoc --backend=xhtml11 \
	 -a lang=XX \
	 --out-file help.html \
	 manual.txt
----

Where +*help.html*+ is the name the help file *must* have, +*manual.txt*+ is the name of your source file and +*XX*+ is the desired locale's language code (e.g. +it+, +es+, ..).

While the Mallard version needs some further steps:

1. Download https://github.com/zykh/mallard-backend/raw/master/mallard.zip[this Mallard backend for AsciiDoc] (documentation https://github.com/zykh/mallard-backend[here])
2. Install the backend
+
----
asciidoc --backend install mallard.zip
----
3. Compile your source file (e.g. +manual.txt+) with:
+
----
asciidoc --backend=mallard \
	 -a chunked=1 \
	 -a toc \
	 --out-file temp.page \
	 manual.txt
----
4. Download https://github.com/zykh/mallard-backend/raw/master/chunkenizer[+chunkenizer+ bash script] (documentation https://github.com/zykh/mallard-backend/blob/master/chunkenizer.adoc[here])
5. Give +chunkenizer+ bash script executable permissions:
+
----
chmod +x chunkenizer
----
6. Process the previously created temp file +temp.page+ with it:
+
----
./chunkenizer --yelp temp.page outdir
----
+
Where +outdir+ is the output directory named after your locale (e.g. +pt_BR+).

[NOTE]
--
If you want to use english manual's images you have to make a symbolic link to their directory in your locale dir:

-----
ln -s ../C/img img
-----
--


[[author]]
Author
------

Daniele Pezzini <[email protected]>