Language Selection

English French German Italian Portuguese Spanish

The Bash Fingertips: Making Your Own 'Information Centre'

Filed under
Howtos

Information Centre

FORGET bloated Web browsers. Forget so-called 'social' media (I call it social control media). They're not efficient, they eat up a lot of memory and CPU cycles, and the interfaces are not consistent (across sites). They're sufficiently distracting and they have ads. They erode privacy. They don't scale well; neither for an aging system (my laptop turns 10 in a few months) nor for users. GUIs are good in particular scenarios, but when the same things are repeated over and over again one might as well set up scripts, automating things and tailoring one's own interfaces, which is easy to achieve (relatively fast and simple) in the command line. It's also more accessible, e.g. over SSH. The pertinent tools are already out there (available for download/installation from repositories), they just need to be put together and programming skills aren't required, just batching in a bash file.

Some years ago I 'developed' a little script (I've been scripting since I was about 12). I called it getswap-sorted.sh and it just ran another script that helped me see what applications use the swap (and how much of it). For the sake of speed I like to restart applications that heavily use swap (i.e. depend on magnetic disk operations). I don't have much RAM. I never had more than 2 GB. getswap-sorted.sh just called out ./getswap.sh | sort -n -k 5 and getswap.sh comes from Erik Ljungstrom. Here it is:

#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`
do
let SUM=$SUM+$SWAP
done
echo "PID=$PID - Swap used: $SUM - ($PROGNAME )"
let OVERALL=$OVERALL+$SUM
SUM=0

done

The output of getswap-sorted.sh would be something like this:


PID=1559 - Swap used: 16472 - (x-terminal-emul )
PID=21980 - Swap used: 16648 - (kwalletd5 )
PID=25548 - Swap used: 16704 - (konversation )
PID=631 - Swap used: 19336 - (kded5 )
PID=23817 - Swap used: 50048 - (pidgin )
PID=23923 - Swap used: 180312 - (thunderbird )


This helps me see which application/process number uses swap and to what degree. It's sorted by the amount of swap taken and the PID helps when I just want to kill a process from the command line (some are small and obsolete anyway).

My script, however, grew bigger over time. I added more things to it, eventually binding it to a special (fifth) mouse key, using xbindkeys -- an immensely valuable and powerful program I've used since around 2004. Extra mouse buttons always seemed worthless (anything more than three), but that's just because there was no program I needed to open or action I needed to invoke often enough. Over time I found that keeping a new terminal one click away (fourth button) and another special terminal also a click away improved my workflow/productivity. I just needed to invest some time in tailoring it. I ended up opening, temporarily, a terminal window with important information displayed, such as weather, disk space (I'm always near the limits), swap usage (I have only 2GB of RAM), uptime, real-time football scores etc. Change of wallpapers was lumped in too, for good measure...

For football tables/scores use one of the following 1) livescore-cli 2) soccer-cli and 3) football-cli.

Sadly, the above CLI football scores' tools got 'stolen' by Microsoft and need to isolate themselves GitHub, in due cource/time. I use the first of the three as it suits my needs best and does not require an API key.

The output looks like this:

 ... Fetching information from www.livescore.com ... 
Displaying Table for Barclay's Premier League
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                Barclay's Premier League TABLE
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 LP     Team Name               GP      W       D       L       GF      GA      GD      Pts
--------------------------------------------------------------------------------------------------
 1      Liverpool               24      19      4       1       55      14      41      61
 2      Tottenham Hotspur       25      19      0       6       51      24      27      57
 3      Manchester City         24      18      2       4       63      19      44      56
 4      Chelsea                 25      15      5       5       45      23      22      50
 5      Arsenal                 24      14      5       5       50      33      17      47
 6      Manchester United       24      13      6       5       48      35      13      45
 7      Wolverhampton Wanderers 25      11      5       9       33      32      1       38
 8      Watford                 25      9       7       9       33      34      -1      34
 9      Everton                 25      9       6       10      36      36      0       33
 10     AFC Bournemouth         25      10      3       12      37      44      -7      33
 11     Leicester City          24      9       5       10      30      30      0       32
 12     West Ham United         24      9       4       11      30      37      -7      31
 13     Brighton & Hove Albion  25      7       6       12      27      36      -9      27
 14     Crystal Palace          25      7       5       13      26      33      -7      26
 15     Newcastle United        25      6       6       13      21      33      -12     24
 16     Southampton             25      5       9       11      27      42      -15     24
 17     Burnley                 25      6       6       13      26      46      -20     24
 18     Cardiff City            25      6       4       15      22      46      -24     22
 19     Fulham                  25      4       5       16      25      55      -30     17
 20     Huddersfield Town       25      2       5       18      13      46      -33     11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 LP = League Position   GP = Games Played       W = Wins        D = Draws       L = Lose 
 GF = Goals For         GA = Goal Against       GD = Goal Differences
--------------------------------------------------------------------------------------------------
 Champions League       Champions League qualification  Europa League
 Europa League qualification    Relegation
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Real-time scores (when matches are on):

 ... Fetching information from www.livescore.com ... 
Displaying Scores for Barclay's Premier League
----------------------------------------------------------------------------
                 Barclay's Premier League SCORES 
----------------------------------------------------------------------------
 January 29  FT     Arsenal                  2 - 1  Cardiff City           
 January 29  FT     Fulham                   4 - 2  Brighton & Hove Albion 
 January 29  FT     Huddersfield Town        0 - 1  Everton                
 January 29  FT     Wolverhampton Wanderers  3 - 0  West Ham United        
 January 29  FT     Manchester United        2 - 2  Burnley                
 January 29  FT     Newcastle United         2 - 1  Manchester City        
 January 30  FT     AFC Bournemouth          4 - 0  Chelsea                
 January 30  FT     Southampton              1 - 1  Crystal Palace         
 January 30  FT     Liverpool                1 - 1  Leicester City         
 January 30  FT     Tottenham Hotspur        2 - 1  Watford                
 February 2  FT     Tottenham Hotspur        1 - 0  Newcastle United       
 February 2  FT     Brighton & Hove Albion   0 - 0  Watford                
 February 2  FT     Burnley                  1 - 1  Southampton            
 February 2  FT     Chelsea                  5 - 0  Huddersfield Town      
 February 2  FT     Crystal Palace           2 - 0  Fulham                 
 February 2  FT     Everton                  1 - 3  Wolverhampton Wanderers
 February 2  FT     Cardiff City             2 - 0  AFC Bournemouth        
 February 3  15:05  Leicester City           ? - ?  Manchester United      
 February 3  17:30  Manchester City          ? - ?  Arsenal                
 February 4  21:00  West Ham United          ? - ?  Liverpool              
----------------------------------------------------------------------------
---------------------------------------

Now putting it all together:


feh --bg-fill --randomize /media/roy/c3fd5b6e-794f-4f24-b3e7-b4ead3722f11/home/roy/Main/Graphics/Wallpapers/Single\ Head/natgeo/* &

livescore -t bpl 

./getswap.sh | sort -n -k 5
 curl -4 http://wttr.in/Manchester
 swapon --summary | grep sda2
 df | grep sda1
uptime

sleep 10

livescore -s bpl 

sleep 40

The first line is feh choosing a wallpaper at random from a collection of award-winning National Geographic photographs. The options and the underlying parameters are self-explanatory.

The football league's table is then shown.

Next, after about 10 seconds of processing, a list of processes will show up based on swap usage (as described above)

The weather at home (Manchester) will then be shown, with colour. Right now I get:

Weather report: Manchester

     \   /     Sunny
      .-.      -5--2 °C       
   ― (   ) ―   ↑ 9 km/h       
      `-’      10 km          
     /   \     0.0 mm         
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤  Sun 03 Feb ├───────────────────────┬──────────────────────────────┐
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│    \  /       Partly cloudy  │      .-.      Light drizzle  │  _`/"".-.     Light rain sho…│               Mist           │
│  _ /"".-.     -4-0 °C        │     (   ).    -2-3 °C        │   ,\_(   ).   1-3 °C         │  _ - _ - _ -  0-3 °C         │
│    \_(   ).   ↑ 12-20 km/h   │    (___(__)   ↑ 17-26 km/h   │    /(___(__)  ↗ 7-14 km/h    │   _ - _ - _   ↑ 9-17 km/h    │
│    /(___(__)  20 km          │     ‘ ‘ ‘ ‘   20 km          │      ‘ ‘ ‘ ‘  16 km          │  _ - _ - _ -  13 km          │
│               0.0 mm | 0%    │    ‘ ‘ ‘ ‘    0.4 mm | 83%   │     ‘ ‘ ‘ ‘   0.4 mm | 65%   │               0.0 mm | 0%    │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤  Mon 04 Feb ├───────────────────────┬──────────────────────────────┐
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│      .-.      Light drizzle  │  _`/"".-.     Patchy rain po…│               Cloudy         │               Cloudy         │
│     (   ).    2-6 °C         │   ,\_(   ).   3-7 °C         │      .--.     1-4 °C         │      .--.     -2 °C          │
│    (___(__)   → 16-26 km/h   │    /(___(__)  → 20-27 km/h   │   .-(    ).   → 13-23 km/h   │   .-(    ).   ↗ 9-16 km/h    │
│     ‘ ‘ ‘ ‘   14 km          │      ‘ ‘ ‘ ‘  18 km          │  (___.__)__)  20 km          │  (___.__)__)  20 km          │
│    ‘ ‘ ‘ ‘    0.3 mm | 88%   │     ‘ ‘ ‘ ‘   0.3 mm | 88%   │               0.0 mm | 0%    │               0.0 mm | 0%    │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤  Tue 05 Feb ├───────────────────────┬──────────────────────────────┐
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│    \  /       Partly cloudy  │               Overcast       │               Overcast       │      .-.      Light drizzle  │
│  _ /"".-.     -1-3 °C        │      .--.     2-6 °C         │      .--.     6 °C           │     (   ).    1 °C           │
│    \_(   ).   ↖ 19-31 km/h   │   .-(    ).   ↑ 23-33 km/h   │   .-(    ).   ↑ 24-40 km/h   │    (___(__)   ↑ 24-40 km/h   │
│    /(___(__)  20 km          │  (___.__)__)  19 km          │  (___.__)__)  8 km           │     ‘ ‘ ‘ ‘   9 km           │
│               0.0 mm | 0%    │               0.0 mm | 0%    │               0.0 mm | 0%    │    ‘ ‘ ‘ ‘    0.3 mm | 0%    │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘


After this I am shown general memory usage and disk usage (for a particular partition) along with uptime thusly:

/dev/sda2                               partition       2097148 381128  -1
/dev/sda1        84035088   77299588   2443660  97% /
 08:03:28 up 116 days, 12:36,  7 users,  load average: 1.70, 1.40, 1.26

It will close on its own after I see what needs seeing, owing to the sleep command. It saves me the clicking (required to then close the window); it just fades away or 'expires', so to speak (until the next time the mouse button gets pressed).

More in Tux Machines

OSS Leftovers

  • 10 Best WordPress Popup Plugins of 2019

    Do you often come across websites that have annoying pop-ups? What do you generally do? Well, oftentimes, an annoying pop-up makes us not only close the pop-up but even the website! As a website owner, you must consider what kind of pop-up will attract a website visitor and make him/her subscribe to your email list. You might have invested a lot on your website but a basic pop-up can turn off your visitor’s interest in your service. On the other hand, even a dull website with an interesting email subscription popup plugins can successfully increase your conversion rate. In this article, we will be discussing the top 10 WordPress Popup Plugin in 2019 which can help you grow your email list exponentially!

  • Apache Software Foundation cofounder Jim Jagielski on the evolution of open source

    Jagielski attended and spoke at the first Mid-Atlantic Developer Conference last year, and said he was impressed by the diversity of the crowd across both demographics as well as tech interests. He saw a reflection of the values of the open source community, which encourages everyone to get involved and views all contributions as useful.

  • Ubisoft joins Blender Development Fund

    Today Ubisoft announced that they will join the Blender Foundation’s Development Fund as a corporate Gold member. Not only will Ubisoft help funding online support for Blender developers, Ubisoft Animation Studio – a department of Ubisoft Film and Television – will also use Blender for their productions and assign developers to contribute to Blender’s open source projects. Pierrot Jacquet, Head of Production at Ubisoft Animation Studio says “Blender was for us an obvious choice: Its strong and engaged community paired up with the vision carried by the Blender Foundation makes it one of the most creative DCC of the market.”

  • ProFTPD Vulnerability Lets Users Copy Files Without Permission [Ed: Troll site BleepingComputer changed headline from "ProFTPD Remote Code Execution Bug Exposes Over 1 Million Servers" to "ProFTPD Vulnerability Lets Users Copy Files Without Permission" (under rare conditions) because that's too much FUD even by its own standards?]

    Under certain conditions, ProFTPD servers are vulnerable to remote code execution and information disclosure attacks after successful exploitation of an arbitrary file copy vulnerability in the mod_copy module. ProFTPd is an open-source and cross-platform FTP server with support for most UNIX-like systems and Windows, and one of the most popular ones targeting the UNIX-based platforms along with Pure-FTPd and vsftpd.

  • Lyft releases open source data set for autonomous vehicle development

    In an effort to bolster the development of cars capable of driving themselves around without human supervision, Lyft today released an autonomous vehicle data set that the company is calling the largest of its kind. It’s freely available in the existing nuScenes format, which was initially developed by Aptiv. “Autonomous vehicles are expected to dramatically redefine the future of transportation. When fully realized, this technology promises to unlock a myriad of societal, environmental, and economic benefits,” said Lyft. “With this, we aim to empower the community, stimulate further development, and share our insights into future opportunities from the perspective of an advanced industrial autonomous vehicles program.”

GIMP review

GIMP (the GNU Image Manipulation Program) is our top pick for the best free photo editor, and comes with a huge array of professional-quality functions for fine-tuning snaps and creating your own artwork from scratch. It includes layers, highly customizable brushes, filters and automatic image-enhancement tools, and support for a huge number of plugins (some pre-installed, and others available to download separately). Its active community of contributors means it’s in constant development, and any bugs are squished in short order. It all adds up to make a truly remarkable free photo editor that’s superior to many commercial programs. Read more

Proprietary Software on GNU/Linux: BricsCAD Shape, WPS Office, Dropbox, and "Mac" Binaries (Through Darling)

  • BricsCAD Shape is a Free SketchUp Alternative for Ubuntu & Linux Mint

    BricsCAD Shape is a free product from CAD software company Bricsys, who offer a range of full-featured (and pricey) CAD software for Windows, macOS and Linux desktops.

  • WPS Office on Linux is a Free Alternative to Microsoft Office

    If you are looking for a free alternative of Microsoft Office on Linux, WPS Office is one of the best choice. It’s free to use and offers compatibility with MS Office document formats. WPS Office is a cross-platform office productivity suite. It is light and fully compatible with Microsoft Office, Google Docs/Sheets/Slide and Adobe PDF. For many users, WPS Office feels intuitive and capable enough to meet their needs. It has gained popularity because of its closeness to Microsoft Office, both in terms of looks and compatibility.

  • Dropbox restores Linux support in new client beta

    That decision saw the sync ‘n’ share giant decide not to support “uncommon” filesystems, leaving it happy to work with just NTFS for Windows, HFS+ or APFS for Mac and Ext4 for Linux. Developers and Linux users were not happy. But their frowns can now turn upside-down, as a support note for the forthcoming Dropbox version 77 client update published today says it will “add support for ZFS (on 64-bit systems only), eCryptFS, XFS(on 64-bit systems only), and Btrfs filesystems in Linux.” The post doesn’t explain Dropbox’s reasons for the change, but it’s not hard to guess its reasons.

  • Darling Progress Report Q2 2019

    James Urquhart's pull requests gave us more stubs for many frameworks including DrawSprocket, AGL, Carbon, CoreServices, and ApplicationServices. Wow, what a list, thank you James! James also fixed a very low level bug where system calls with large numbers of arguments wouldn't work properly for 32-bit applications. Finally, he fixed a problem where Darling was using clock_sleep instead of clock_nanosleep and a bug with the stat system call.

  • Darling Picks Up New Contributors For Its macOS Compatibility Layer On Linux

    Darling is the long-standing (albeit for some years idling) effort to allow macOS binaries to run on Linux that is akin to Wine but focused on an Apple macOS layer rather than Windows. This summer it's been moving along and seeing some new developer contributions. The Darling project just published their Q2 highlights with having new contributors onboard and making progress at varying levels of the stack. They have begun stubbing out more frameworks including AGL, Carbon, AddressBook, CoreServices, and ApplicationServices.

(GNU/)Linux on Devices: Librem/Purism, Congatec, Aaeon, Axiomtek

  • Librem One Design Principles: Simple, Secure Applications

    The primary appeal of Librem One is that you get privacy without sacrificing convenience. There is already a wealth of free software available, both applications and services, with numerous security and privacy options. However, learning what they are and keeping up-to-date is generally neither simple nor convenient.

  • Type 6 module adds support for 10 new Intel 9th Gen CPUs

    Congatec’s Linux-friendly “Conga-TS370” COM Express Type 6 module now supports 10 new 9th Gen Coffee Lake-H Refresh chips including a 4.1GHz hexa-core, dual-threaded i7-9850HL with a 25W TDP. There’s also a new Conga-TEVAL/COMe 3.0 carrier. Last month, Kontron announced that its Intel 8th Gen Coffee Lake based COMe-bCL6 COM Express Basic Type 6 module had been updated to support Intel’s 9th Gen Coffee Lake Refresh chips. Now, rival German embedded vendor Congatec has stepped up with its own 9th Gen refresh of its 8th Gen Conga-TS370 Basic Type 6 module. You can now order the Conga-TS370 with 14 Intel Core, Xeon, Pentium, and Celeron models, including 10 new 9th Gen chips.

  • Aaeon unveils first Kaby Lake based SDM-S display module

    Aaeon announced a Linux-ready Intel SDM-Small module with a 7th Gen Intel Core CPU. The credit card sized “ASDM-S-KBU” is designed for kiosks, vending machines, and signage applications. Earlier this month we started seeing the first products to support Intel’s 175 x 100 x 20mm Smart Display Module-Large form factor for easily serviceable and upgradable signage control boards. Nexcom’s NDiS S538 module runs on an Intel 6th Gen Core CPU and Axiomtek’s SDM500L taps the newer 8th Gen Whiskey Lake-U. Now Aaeon has announced a board that adopts the smaller, 100 x 60 x 20mm Intel SDM-Small (SDM-S) spec. The ASDM-S-KBU is billed as the first SDM-S module based on a 7th Gen Kaby Lake chip.

  • Apollo Lake Pico-ITX SBC supplies mini-PCIe and M.2 expansion

    Axiomtek’s “PICO319” SBC is built around a quad-core Atom x5-E3940 SoC and offers 2x GbE, 2x USB 3.0, DP and LVDS, mini-PCIe and M.2, and -40 to 70°C support. The PICO319 is the latest of several Axiomtek Pico-ITX boards with an Intel Apollo Lake processor, including last year’s PICO316. The PICO319 incorporates the quad-core, up to 1.8GHz Atom x5-E3940 instead of the PICO316’s choice of a Pentium N4200 or Celeron N3350. The Atom x5-E3940 enables the PICO319 to support a wider temperature range of -40 to 70°C. No OS support was listed, but the earlier PICO316 supports Linux (Red Hat, Fedora, Ubuntu) and Windows.