Showing posts with label Conky. Show all posts
Showing posts with label Conky. Show all posts

Tuesday, March 23, 2021

Update notifications in Conky

 

An improved Conky system updates notification for Debian (The first version and information on how to enable package list update if you are not using Gnome, which I assume you're not, as Gnome already has update notifications.). This one includes the time of the last package list update so you can see that the system is actually checking for updates, and tells you if there are any security updates (it should list package names to if there are security updates, but I haven't been able to test this yet.) The script requires aptitude.

I used the following code:

Linux - display or upgrade security updates only using apt

How to know last time `apt-get update` was executed?

if_match in Conky

DevHumor

Here's the code:

${if_match ${execi 1800 aptitude search "~U" | wc -l}==0}\ ${alignr}No updates available ${alignr}${color grey}Last check:${color} ${execi 1800 ls -l /var/cache/apt/pkgcache.bin | awk '{print $6,$7,$8}'} ${else}${alignr}Updates available: ${execi 1800 aptitude search "~U" | wc -l} ${alignr}Security: ${execi 1800 aptitude search '~U ~ODebian' -F "%p %O"|awk '/Debian-Security/' | wc -l}  ${execi 1800 aptitude search '~U ~ODebian' -F "%p %O"|awk '/Debian-Security/ {print $1}'} ${endif}

EDIT:

Replaced

${execi 1800 ls -l /var/cache/apt/pkgcache.bin | cut -d' ' -f6,7,8}

with

${execi 1800 ls -l /var/cache/apt/pkgcache.bin | awk '{print $6,$7,$8}'}

The first command would only output the date when the date was one digit only.

[Edit 24/8/21: Bullseye is now released and the first security updates have arrived, allowing me to test the script. I have corrected a typo which meant number of security updates was not displayed.]




Monday, March 8, 2021

A simple Conky weather script

The script requires ansiweather. It's pretty much self explanatory. Add your town and country code, comment out items you don't want, or double up for extra locations.

#!/bin/bash
#dontsurfinthenude.blogspot.com/

location=london,GB
#try city,country code or look up at openweathermap.org
data_metric=$(ansiweather -l $location -u metric -s true -a false -d true)
data_imperial=$(ansiweather -l $location -u imperial -s true -a false -d true)
#comment out one if you want only metric or only imperial
forecast=$(ansiweather -l $location -u metric -s true -a false -f 7)

echo "W E A T H E R"
echo ""
echo "$data_metric" | awk '{print $3,$5$6,$7}'#city,temp,°C
#echo "$data_imperial" | awk '{print $3,$5$6,$7}'#city,temp,°F
echo ""
echo "$data_imperial" | awk '{print $9,$11,$12,$13}'#wind,mph
#echo "$data_metric" | awk '{print $9,$11,$12,$13}'#wind,m/s
echo "$data_metric" | awk '{print $15,$17$18}'#humidity
echo "$data_metric" | awk '{print $20,$22,$23}'#pressure,hPa
#echo "$data_imperial" | awk '{print $20,$22,$23}'#pressure,inHg
echo ""
echo "$data_metric" | awk '{printf "%7s %.5s %s\n", $25,$29,$30}'#sunrise
echo "$data_metric" | awk '{printf "%-7s %.5s %s\n", $32,$36,$37}'#sunset 
echo ""
echo "Forecast"
echo ""
echo "$forecast" | awk 'BEGIN {format="%s %7s%s  %s\n"}
            {printf format, $4,$7,$8,$9}
            {printf format, $11,$14,$15,$16}
            {printf format, $18,$21,$22,$23}
            {printf format, $25,$28,$29,$30}
            {printf format, $32,$35,$36,$37}
            {printf format, $39,$42,$43,$44}
            {printf format, $46,$49,$50,$51}'
echo ""
echo openweather.org



Sunday, February 10, 2013

Check GMail script for Conky on Crunchbang Waldorf

I'm trying out Crunchbang Waldorf. I found a script for Crunchbang Statler (the previous version) that displayed the number of my new GMail messages in my Conky desktop display, but it didn't work with Waldorf. I was looking around for a simple and efficient script and eventually found one that works on the Arch Linux forum.


 I modified it a little not to show the number of emails on the server, just the number of new emails.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import sys, imaplib

port = 993
server = 'imap.gmail.com'

username = 'name@gmail.com'
passwd = 'password'

imap_server = imaplib.IMAP4_SSL(server, port)
try:
    imap_server.login(username, passwd)
except:
    print('?? new')
    sys.exit( 1 )

typ, data = imap_server.select ('Inbox', True)
if typ == 'OK':
    total = int(data[0])
    typ, data = imap_server.search (None, 'SEEN')
    if typ == 'OK':
        seen = len(data[0].split())
        print('{} new'.format(total - seen))

if typ != 'OK':
    print('?? new')

imap_server.logout()
 Credit: rockin turtle.

Sunday, February 19, 2012

Conky in CruchBang

I've been playing around with CrunchBang recently. It's elegantly functional, in a minimalist way. It comes with Conky enabled by default. The default desktop seems to be designed for people who enjoy sitting in the dark wondering exactly what their computer is doing.


I messed about with my set up to see if I could reduce Conky to something more minimal, and also added one of my favourite wallpapers, something a little more light and airy and interesting to look at when I see the desktop.


Here's a close up of Conky:


The Gmail indicator uses this script, and the weather indicator this script (see this post for how to set up the location if you're not in the US).

If you try something similar, and wonder how to get Conky to display #!,put a "\" before the "#", which otherwise will turn the line into a comment.
${alignc}${font Liberation Sans:size=26}\#!${font}