I wanted to ask how can I develop a simple script/app and put it in the status bar near the time (top right). Let's say I have a laptop and the script gets the battery current usage in watts every 10 seconds so it is shown in the status bar. Am using ubuntu 16 with unity
Instead of counting monkeys :-), I modified the second script from L. D. James's answer to show the current power consumption of my laptop in watts.
The script works with Ubuntu 16.04 and probably the only system specific thing is the file where the value of the current power consumption is stored. In my case I found it by the help of
tlp
:Note some devices provide the current power consumption in watts, but some devices provide the current values of the voltage and the current (amps) - and the script covers these cases.
Further I created the GitHub Project PowerNow and added additional options: to execute
htop
,powertop
ortlp stat
within agnome-terminal
.Installation of the Python script
powerNow
and optionally Startup Applications (and ~/Desktop).desktop
files:Copy the script to
/usr/local/bin
to make it accessible as shell command system wide:Copy the script to
~/bin
to make it accessible only for the current user:Copy the desktop file to
~/Desktop
(the script is required):Copy the desktop file to
~/.config/autostart
(the script is required):Ubuntu provides a set of libraries and examples for using them to for a migration of simple menus and a consistent interface.
The examples in the document linked above includes version is the following languages:
A python` example from the page is:
You could use a program from the list as a wrapper for your script so that clicking on the item will call your script.
Making Icon and text dynamic
(Taken from: How can I write a dynamically updated panel app / indicator?)
This example suggests using
GObject
. Callgobject.threads_init()
an application initialization. Then launch your threads normally, but make sure the threads never do any GUI task directly. Instead, you usegobject.idle_add
to schedule GUI task directly. (The above is an exact quote from the link included in case the link stops working.)