Linux Format - UK (2019-12)

(Antfer) #1
http://www.techradar.com/pro/linux December 2019 LXF257 61

Terminal dashboard TUTORIALS


modules directory, which should help you decide how
to flesh out WTF, as the default is rather vanilla.
A typical desktop user works with a number of
different applications at any given time. This usually
means switching between different applications every
now and then to check for updates. This is where a
dashboard such as WTF really shines. You can
configure it to display upcoming events in Google
Calendar, the status of downloads in Transmission,
battery statistics, your favourite subReddit, feeds from
Twitter, the output from a command and so on. These
different functionalities are provided with the use of
Modules, which the project defines as discrete units
that extract data from some source and presents it to
users within the interface.
When you run WTF for the first time with the wtfutil
command, it displays its configuration file ~/.config/
wtf/config.yml in a pane on the left. The rest of the
interface is littered with clocks, battery status and
uptime information. There’s also a rudimentary feed
reader, which by default displays entries from the
project’s blog. Each of these separate panes within the
interface is referred to as a widget, and you can also
tweak the height and width of the rows and columns
that make up the different widgets.
For each module you want to enable, you must also
provide its position within the interface and dimensions:
prettyweather:
enabled: true
city: “California”
position:
top: 0
left: 0
height: 1
width: 1
refreshinterval: 300
unit: “m”
view: 0
language: “en”
The different settings are self-explanatory, except
for the position, which we discuss in detail in the box on
the opposite page. You can similarly add a widget to
display the status of torrents in Transmission by adding
the following code block to ~/.config/wtf/config.yml:
transmission:
enabled: true
username: linuxlala
password: xindinx01
position:
top: 0
left: 3
height: 1
width: 1
refreshinterval: 1
Its important that you spend some time with the
default config file, as well as the others in the _sample_
config directory. When adding new modules into the
config file, you must strictly adhere to the space and
tab convention as used in the file. Otherwise, WTF
points out the exact line which is not in the expected
conformity and exits with an error:
ERROR Could not load ‘config.yml’.

This could mean one of two things:


  1. Your config.yml file is missing. Check in ~/.config/
    wtf/ to see if config.yml is there.

  2. Your config.yml file has a syntax error. Try
    running it through http://www.yamllint.com to check
    for errors.
    Error: yaml: line 101: did not find expected key
    This is why you must refer to the documentation on
    the project’s homepage at https://wtfutil.com that
    discusses all the available modules, as well as the
    different settings you must provide for each to get them
    working. At the very least, this will give you an idea of
    how to define the different settings, the options that are
    available for use with different modules.
    Although the documentation is helpful, it doesn’t
    always provide all the pertinent details to enable
    novices to work with the different modules. For
    instance, you must have transmission-daemon running
    on your machine, and enable user login before you can
    the Transmission module to keep tabs on the status of
    your downloads.


Interactive widgets
One of the most interesting settings in WTF is
shortcuts= true. Some of the widgets in WTF, such as
todo, transmission, hackernews, feedreader and so on
are user interactive. Unlike other widgets such as
prettyweather, status and battery, these interactive
widgets enable you to scroll, edit, update and otherwise
control the information provided. For instance, the
Transmission widget lets you start/pause a torrent, or
delete it altogether. Similarly, the Todo widget can be
used to add a new task to the todo list, mark completed
tasks, move the tasks up or down in priority and so on.
If the shortcuts option is set to true , the interactive
widgets in your WTF interface are each assigned a
unique numerical identifier. You can then press this
number to select the relevant widget. Press / for a list
of possible actions you can take to interact with the
information provided within the widget. The currently
selected interactive widget is highlighted with a
differently coloured border for easy identification.
There are some command-line warriors who claim to
achieve the same degree of efficiency with Screen and
Tmux, but WTF requires almost no head-scratching at
all to install and tweak to your liking. The low barrier to
entry, coupled with the possibility of the project being
straightforward enough to help you learn the basics of
the Go programming language, are reasons enough to
give it a fair shake.

ENHANCE YOUR TERMINAL-FU Subscribe now at http://bit.ly/LinuxFormat


WTF uses the
tcell and tview
projects to
control the
appearance of
widgets within
the terminal.
If you’ve ever
wanted to
create custom
widgets for
the terminal,
or otherwise
master the Go
programming
language
with the use
of simple,
straightforward
projects, WTF
and tview
make prime
candidates.

WTF will
automatically
update the widgets
as you edit the
~/.config/config.
yml file, so you
don’t have to
constantly restart
the tool for
the changes to
take effect.

6660Decmbr rb0c219ab29shodu December 2019 LXF257 61


Terminal dashboard TUTORIALS


modules directory, which should help you decide how
to flesh out WTF, as the default is rather vanilla.
A typical desktop user works with a number of
different applications at any given time. This usually
means switching between different applications every
now and then to check for updates. This is where a
dashboard such as WTF really shines. You can
configure it to display upcoming events in Google
Calendar, the status of downloads in Transmission,
battery statistics, your favourite subReddit, feeds from
Twitter, the output from a command and so on. These
different functionalities are provided with the use of
Modules, which the project defines as discrete units
that extract data from some source and presents it to
users within the interface.
When you run WTF for the first time with the wtfutil
command, it displays its configuration file ~/.config/
wtf/config.yml in a pane on the left. The rest of the
interface is littered with clocks, battery status and
uptime information. There’s also a rudimentary feed
reader, which by default displays entries from the
project’s blog. Each of these separate panes within the
interface is referred to as a widget, and you can also
tweak the height and width of the rows and columns
that make up the different widgets.
For each module you want to enable, you must also
provide its position within the interface and dimensions:
prettyweather:
enabled: true
city: “California”
position:
top: 0
left: 0
height: 1
width: 1
refreshinterval: 300
unit: “m”
view: 0
language: “en”
The different settings are self-explanatory, except
for the position, which we discuss in detail in the box on
the opposite page. You can similarly add a widget to
display the status of torrents in Transmission by adding
the following code block to ~/.config/wtf/config.yml:
transmission:
enabled: true
username: linuxlala
password: xindinx01
position:
top: 0
left: 3
height: 1
width: 1
refreshinterval: 1
Its important that you spend some time with the
default config file, as well as the others in the sample
config directory. When adding new modules into the
config file, you must strictly adhere to the space and
tab convention as used in the file. Otherwise, WTF
points out the exact line which is not in the expected
conformity and exits with an error:
ERROR Could not load ‘config.yml’.


This could mean one of two things:


  1. Your config.yml file is missing. Check in ~/.config/
    wtf/ to see if config.yml is there.

  2. Your config.yml file has a syntax error. Try
    running it through http://www.yamllint.com to check
    for errors.
    Error: yaml: line 101: did not find expected key
    This is why you must refer to the documentation on
    the project’s homepage at https://wtfutil.com that
    discusses all the available modules, as well as the
    different settings you must provide for each to get them
    working. At the very least, this will give you an idea of
    how to define the different settings, the options that are
    available for use with different modules.
    Although the documentation is helpful, it doesn’t
    always provide all the pertinent details to enable
    novices to work with the different modules. For
    instance, you must have transmission-daemon running
    on your machine, and enable user login before you can
    the Transmission module to keep tabs on the status of
    your downloads.


Interactive widgets
One of the most interesting settings in WTF is
shortcuts= true. Some of the widgets in WTF, such as
todo, transmission, hackernews, feedreader and so on
are user interactive. Unlike other widgets such as
prettyweather, status and battery, these interactive
widgets enable you to scroll, edit, update and otherwise
control the information provided. For instance, the
Transmission widget lets you start/pause a torrent, or
delete it altogether. Similarly, the Todo widget can be
used to add a new task to the todo list, mark completed
tasks, move the tasks up or down in priority and so on.
If the shortcuts option is set to true , the interactive
widgets in your WTF interface are each assigned a
unique numerical identifier. You can then press this
number to select the relevant widget. Press / for a list
of possible actions you can take to interact with the
information provided within the widget. The currently
selected interactive widget is highlighted with a
differently coloured border for easy identification.
There are some command-line warriors who claim to
achieve the same degree of efficiency with Screen and
Tmux, but WTF requires almost no head-scratching at
all to install and tweak to your liking. The low barrier to
entry, coupled with the possibility of the project being
straightforward enough to help you learn the basics of
the Go programming language, are reasons enough to
give it a fair shake.

ENHANCE YOUR TERMINAL-FU Subscribe now at http://bit.ly/LinuxFormat


WTFusesthe
tcellandtview
projectsto
controlthe
appearanceof
widgetswithin
theterminal.
If you’veever
wantedto
createcustom
widgetsfor
theterminal,
orotherwise
mastertheGo
programming
language
withtheuse
ofsimple,
straightforward
projects,WTF
andtview
makeprime
candidates.

WTF will
automatically
update the widgets
as you edit the
~/.config/config.
yml file, so you
don’t have to
constantly restart
the tool for
the changes to
take effect.
Free download pdf