Difference between revisions of "Conky"

From ArchWiki
Jump to: navigation, search
m (style, move from .conky to .scripts as .conky is no longer used by default)
 
(114 intermediate revisions by 52 users not shown)
Line 1: Line 1:
 
[[Category:Status monitoring and notification]]
 
[[Category:Status monitoring and notification]]
 +
[[fa:Conky]]
 +
[[de:Conky]]
 
[[es:Conky]]
 
[[es:Conky]]
 
[[fr:Conky]]
 
[[fr:Conky]]
 
[[it:Conky]]
 
[[it:Conky]]
 +
[[ja:Conky]]
 
[[ru:Conky]]
 
[[ru:Conky]]
 
[[tr:Conky]]
 
[[tr:Conky]]
[[zh-CN:Conky]]
+
[[zh-hans:Conky]]
Conky is a system monitor software for the X Window System. It is available for GNU/Linux and FreeBSD. It is free software released under the terms of the GPL license. Conky is able to monitor many system variables including CPU, memory, swap, disk space, temperature, top, upload, download, system messages, and much more. It is extremely configurable, however, the configuration can be a little hard to understand. Conky is a fork of torsmo.
+
{{Style|Lots of useless config dumps and unneeded complexity}}
 +
''Conky'' is a system monitor software for the X Window System. It is available for GNU/Linux and FreeBSD. It is free software released under the terms of the GPL license. Conky is able to monitor many system variables including CPU, memory, swap, disk space, temperature, top, upload, download, system messages, and much more. It is extremely configurable, however, the configuration can be a little hard to understand. ''Conky'' is a fork of torsmo.
  
==Installation and configuration==
+
== Installation and configuration ==
*[[pacman|Install]] the {{Pkg|conky}} package which is available in the [[Official Repositories|official repositories]].
 
*Edit the {{ic|~/.conkyrc}} config file using an example configuration file from [http://conky.sourceforge.net/screenshots.html homeproject-screenshot]
 
When editing your config file, you will see immediately the effect of any change as soon as you save it. There is no need to log out/log in your X session. So best is to test all kind of options, one by one, save the configuration file and see the change on your conky window, and correct if your change is unappropriated.
 
*Alternatively, you can use the default config at {{ic|/etc/conky/conky.conf}}:
 
$ cp /etc/conky/conky.conf ~/.conkyrc
 
Best is to use a local {{ic|~/.conkyrc}} config.
 
As many apps, conky will first try to look for a local {{ic|.conkyrc}} file. If this one doesn't exist, then it will read the default one in {{ic|/etc/conky}}.
 
  
In case you store your configuration locally, e.g. in your home directory, you will not be able to read any log files unless you do some changes. One of the nice features of conky is to pipe to your desktop some {{ic|/var/log/}} files to read all kinds of log messages. Most of these files can only be read by {{ic|root}}, and you will thus need to {{ic|sudo}} conky. Starting conky as {{ic|root}} is not recommended, so you will need to make this following changes:
+
[[Install]] the {{Pkg|conky}} package. For alternative packages with more features, see [[#AUR packages]].
$ usermod -aG log username
 
You add {{ic|username}} to the {{ic|log group}}. Now {{ic|username}} can read log files, and you will be able to redirect log messages with conky on your desktop.
 
  
* If conky does not accept changes -- e.g. minimum_size -- you made to {{ic|~/.conkyrc}} make sure you cleared {{ic|/etc/conky/conky.conf}} or commented out the relevant section.Best is to remove files in {{ic|/etc/conky/}}, as conky will keep reading them and this can give you some Xorg error messages.
+
Create a local configuration file:
 +
$ mkdir -p ~/.config/conky
 +
$ conky -C > ~/.config/conky/conky.conf
  
==AUR packages==
+
Now you can edit {{ic|~/.config/conky/conky.conf}} to customize conky as you wish. For a few example configuration files, see [https://github.com/brndnmtthws/conky/wiki/User-Configs this page].
  
In addition to the basic {{Pkg|conky}} package in the [[Official Repositories|official repositories]], there are various [[Arch User Repository|AUR]] packages available with extra compile options enabled.
+
When editing your config file, you will see immediately the effect of any change as soon as you save it. There is no need to log out/log in your X session. So best is to test all kind of options, one by one, save the configuration file and see the change on your ''conky'' window, and correct if your change is inappropriate.
  
*Install {{AUR|conky-cli}} for conky without X11 dependencies
+
One of the nice features of ''conky'' is to pipe to your desktop some {{ic|/var/log/}} files to read all kinds of log messages. Most of these files can only be read by {{ic|root}}, but running ''conky'' as {{ic|root}} is not recommended, so you will need to add {{ic|''username''}} to the {{ic|log}} group:
*Install {{AUR|conky-nvidia}} for nvidia support.
+
# usermod -aG log ''username''
*Install {{AUR|conky-lua}} for lua support.
 
*Install {{AUR|conky-lua-nv}} for both lua and nvidia support.
 
  
==Tips and tricks==
+
=== AUR packages ===
===Enable real transparency in KDE4 and XFCE4===
 
Since version 1.8.0, Conky suppports real transparency. To enable it add this line to {{ic|~/.conkyrc}}:
 
own_window_transparent yes
 
  
The above option is not desired with the {{ic|OWN_WINDOW_ARGB_VISUAL yes}} option.
+
In addition to the basic ''conky'' package, there are various [[AUR]] packages available with extra compile options enabled:
This replaces the {{Pkg|feh}} method described below.
 
  
===Autostart with xfce4===
+
* {{App|conky-cli|''Conky'' without X11 dependencies||{{AUR|conky-cli}}}}
In {{ic|.conkyrc}} file:
+
* {{App|conky-lua|''Conky'' with Lua support||{{AUR|conky-lua}}}}
background yes
+
* {{App|conky-lua-nv|''Conky'' with both Lua and Nvidia support||{{AUR|conky-lua-nv}}}}
 +
* {{App|conky-nvidia|''Conky'' with Nvidia support||{{AUR|conky-nvidia}}}}
  
This variable will fork Conky to your background.
+
== Tips and tricks ==
If you want to make your window always visible on your desktop, sticky across all workspaces and not showing in your taskbar, add these arguments:
+
 
  own_window yes
+
=== Config file syntax changed ===
  own_window_type override
+
 
The override option makes your window out of control of your window manager.
+
Since Conky 1.10, configuration files have been written with Lua syntax, like so:
 +
 
 +
  conky.config = {
 +
    -- Comments start with a double dash
 +
    bool_value = true,
 +
    string_value = 'foo',
 +
    int_value = 42,
 +
  }
 +
  conky.text = [[
 +
  $variable
 +
  ${evaluated variable}
 +
  ]]
 +
 
 +
Some examples below may still use the old syntax, which looks like this:
 +
 
 +
  bool_value yes
 +
  string_value 'foo'
 +
  int_value 42
 +
 
 +
A Lua script is available to convert from the old syntax to the new Lua syntax [https://github.com/brndnmtthws/conky/blob/master/extras/convert.lua here].
 +
 
 +
If in doubt, or something doesn't work at all, you can start with the default config file:
 +
 
 +
  $ conky -C > conky.conf.default
 +
 
 +
=== Enable real transparency ===
 +
 
 +
To enable real transparency, add this line to {{ic|conky.conf}}:
 +
 
 +
own_window_transparent = true,
 +
 
 +
The above option is not desired with the {{ic|1=own_window_argb_visual = true}} option.
 +
 
 +
If transparency doesn't work you might need to follow [[#Universal method to enable true transparency]].
 +
 
 +
{{Note|1=[[Xfce]] requires enabled compositing, see [https://forum.xfce.org/viewtopic.php?pid=25939].}}
 +
 
 +
=== Autostart ===
 +
 
 +
In {{ic|conky.conf}} file:
 +
background = true,
 +
 
 +
This variable will fork ''conky'' to your background. If you want to make your window always visible on your desktop, sticky across all workspaces and not showing in your taskbar, add these arguments:
 +
  own_window = true,
 +
  own_window_type = 'override',
 +
 
 +
The {{ic|override}} takes ''conky'' out of the control of your window manager.
  
 
Add a {{ic|~/.config/autostart/conky.desktop}}:
 
Add a {{ic|~/.config/autostart/conky.desktop}}:
[Desktop Entry]
+
{{hc|conky.desktop|2=
Encoding=UTF-8
+
[Desktop Entry]
Version=0.9.4
+
Type=Application
Type=Application
+
Name=conky
Name=conky
+
Exec=conky -d
Comment=
+
StartupNotify=false
Exec=conky -d
+
Terminal=false
StartupNotify=false
+
}}
Terminal=false
+
 
Hidden=false
+
You may want to add ''-p 10'' to the ''Exec'' parameter so that it starts drawing ''conky'' after the desktop is up (''-p 10'' means pause for 10 seconds at startup before doing anything).
 +
 
 +
=== Prevent flickering ===
 +
 
 +
''Conky'' needs Double Buffer Extension (DBE) support from the X server to prevent flickering because it cannot update the window fast enough without it. It can be enabled in {{ic|/etc/X11/xorg.conf}} with {{ic|Load "dbe"}} line in {{ic|"Module"}} section. The {{ic|xorg.conf}} file has been replaced (1.8.x patch upwards) by {{ic|/etc/X11/xorg.conf.d}} which contains the particular configuration files. ''DBE'' is loaded automatically.
  
===Prevent flickering===
+
To enable double buffering, add the option
Conky needs Double Buffer Extension (DBE) support from the X server to prevent flickering because it cannot update the window fast enough without it. It can be enabled in {{ic|/etc/X11/xorg.conf}} with {{ic|Load "dbe"}} line in {{ic|Section "Module"}}. The xorg.conf file has been replaced (1.8.x patch upwards) by {{ic|/etc/X11/xorg.conf.d}} which contains the particular configuration files. ''DBE'' is loaded automatically.
 
  
To verify:
+
  double_buffer = true,
$ grep dbe /var/log/Xorg.0.log
 
  
Output (should be similar):
+
to your {{ic|conky.conf}}.
[  3286.101] (II) LoadModule: "dbe"
 
[  3286.101] (II) Loading /usr/lib/xorg/modules/extensions/libdbe.so
 
[  3286.111] (II) Module dbe: vendor="X.Org Foundation"
 
  
To enable double-buffer check to have in {{ic|~/.conkyrc}}:
+
=== Custom colors ===
# Place below the other options, not below TEXT or XY
 
double_buffer yes
 
  
===Custom colors===
+
Aside the classic preset colors (white, black, yellow...), you can set your own custom color using the color name code. To determine the code of a color, use a color selector app. The basic {{Pkg|gcolor2}} package in the [[official repositories]] will give you the color name. It is made of six hexadecimal digits (0-9, A-F).
Aside the classic preset colors (white, black, yellow...), you can set your own custom color using the color name code. To determine the code of a color, use a color selector app. The basic {{pkg|gcolor2}} package in the [[Official Repositories|official repositories]] will give you the color name. It is made of a series of letters and numbers.
 
 
Add this line in your configuration file for a custom color:
 
Add this line in your configuration file for a custom color:
color1    Colorname1
 
color2    Colorname2
 
Then, when editing the TEXT section, use custom color number previously defined.
 
  
===Dual Screen===
+
  color0 = 'white', --convention for standard named colors
When using a dual screen configuration, you will need to play with two options to place your conky window.
+
  color1 = '00CC00', --convention for hex colors: no pound sign
Let's say you are running a 1680X1050 pixels resolution, and you want the window on middle top of your left monitor, you will use this:
+
 
  alignment top_left
+
Then, when editing the {{ic|TEXT}} section, use custom color number previously defined, for example {{ic|${color3} }}.
  gap_X 840
+
 
The alignment option is trivial, and gap_X option is the distance, in pixels, from the left border of your screen.
+
=== Dual Screen ===
 +
 
 +
When using a dual screen configuration, you will need to play with two options to place your ''conky'' window. Let's say you are running a 1680X1050 pixels resolution, and you want the window on middle top of your left monitor, you will use this:
 +
  alignment = 'top_left',
 +
  gap_X = 840,
 +
 
 +
The {{ic|alignment}} option is trivial, and {{ic|gap_X}} option is the distance, in pixels, from the left border of your screen.
 +
 
 +
The {{ic|xinerama_head}} option might also need to be set.
 +
 
 +
=== Do not minimize on Show Desktop ===
 +
 
 +
'''Using Compiz:''' If the 'Show Desktop' button or key-binding minimizes Conky along with all other windows, start the Compiz configuration settings manager, go to "General Options" and uncheck the "Hide Skip Taskbar Windows" option.
 +
 
 +
If you do not use Compiz, try editing {{ic|conky.conf}} and adding/changing the following line:
 +
 
 +
own_window_type = 'override',
 +
 
 +
or
 +
 
 +
own_window_type = 'desktop',
 +
 
 +
Refer to ''conky''s man page for the exact differences. But the latter option enables you to snap windows to ''conky''s border using resize key-binds in e.g. Openbox, which the first one does not.
  
===Do not minimize on Show Desktop (Compiz)===
+
=== Integrate with GNOME Shell ===
If the 'Show Desktop' button or key-binding minimizes Conky along with all other windows, start the Compiz configuration settings manager, go to "General Options" and uncheck the "Hide Skip Taskbar Windows" option.
 
  
===Integrate with Gnome 3+===
+
Some have experienced problems with ''conky'' showing up under [[GNOME]].
Some have experienced problems with Conky showing up under Gnome 3.
 
*Add these lines to {{ic|~/.conkyrc}}:
 
own_window yes
 
own_window_type conky
 
own_window_transparent yes
 
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
 
  
===Integrate with KDesktop===
+
Add these lines to {{ic|conky.conf}}:
Conky with screenshot configuration generate problems with icons visualization. So there are some steps to follow.
+
  own_window = true,
*Add these lines to {{ic|~/.conkyrc}}:
+
  own_window_type = 'desktop',
  own_window yes
 
  own_window_type normal
 
own_window_transparent yes
 
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
 
*If this setting is on, comment it out or delete the line:
 
minimum_size
 
*To automatically start Conky, create this symlink:
 
$ ln -s /usr/bin/conky ~/.kde/share/autostart/conkylink
 
For KDE4 users:
 
$ ln -s /usr/bin/conky ~/.kde4/Autostart/conkylink
 
*[[pacman|Install]] the {{Pkg|feh}} package which is available in the [[Official Repositories|official repositories]].
 
*Make a script to allow transparency with the desktop
 
For KDE3 users
 
$ nano -w ~/.kde/share/autostart/fehconky
 
  
  #!/bin/bash
+
For transparency, also add these:
  feh --bg-scale `dcop kdesktop KBackgroundIface currentWallpaper 1`
+
  own_window_transparent = true,
For KDE4 users
+
  own_window_argb_visual = true,
  $ nano -w ~/.kde4/Autostart/fehconky
+
  own_window_argb_value = 255,
  
#!/bin/bash
+
=== Display package update information ===
feh --bg-scale "`grep 'wallpaper=' ~/.kde4/share/config/plasma-desktop-appletsrc | tail --lines=1 | sed 's/wallpaper=//'`"
 
use {{ic|--bg-center}} if you use a centered wallpaper.
 
*Make it executable
 
$ chmod +x ~/.kde/share/autostart/fehconky
 
KDE4
 
$ chmod +x ~/.kde4/Autostart/fehconky
 
*Instead of using a script, you can add the corresponding line to the bottom of {{ic|~/.conkyrc}}
 
For KDE3
 
${exec feh --bg-scale `dcop kdesktop KBackgroundIface currentWallpaper 1`}
 
For KDE4
 
${exec feh --bg-scale "`grep 'wallpaper=' ~/.kde4/share/config/plasma-desktop-appletsrc | tail --lines=1 | sed 's/wallpaper=//'`"}
 
  
===Integrate with Razor-qt===
+
[[Pacman]] provides its own script called {{ic|checkupdates}} which displays package updates from the official repos. Use {{ic|<nowiki>${execpi 3600 checkupdates | wc -l}</nowiki>}} to display the total number of packages.
With Conky's default configuration, its window might disappear from the desktop when you click on the latter.
 
Here's how to configure Conky to stick on your Razor-qt desktop:
 
*Add these lines to:
 
{{hc|~/.conkyrc|own_window yes
 
own_window_class Conky
 
own_window_type normal
 
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
 
own_window_transparent yes
 
}}
 
  
===Display package update information===
+
=== Display weather forecast ===
*[https://bbs.archlinux.org/viewtopic.php?id=68104 Paconky] - Displays package update information in a user-defined format. The output of this program can be included in Conky with the {{ic|<nowiki>${execpi}</nowiki>}} command.
 
*[https://bbs.archlinux.org/viewtopic.php?id=53761 Scrolling Notifications] - Prints scrolling update notifications. From the author of Paconky.
 
*[https://bbs.archlinux.org/viewtopic.php?id=57291 Perl Script] - Simpler and earlier script from the author of Paconky. Prints only the number of packages needing an update.
 
*[https://bbs.archlinux.org/viewtopic.php?id=37284 Python Script] - Fairly configurable update notification program in [[Python]].
 
*[https://bbs.archlinux.org/viewtopic.php?pid=483742#p483742 Bash Script] - [[Bash]] script for users that have enabled ShowSize.
 
  
===Display weather forecast===
 
 
See [https://bbs.archlinux.org/viewtopic.php?id=37381 this thread].
 
See [https://bbs.archlinux.org/viewtopic.php?id=37381 this thread].
  
===Display RSS feeds===
+
=== Display a countdown timer ===
Conky has the ability to display RSS feeds natively without the need for an outside script to run and output into Conky. For example, to display the titles of the ten most recent Planet Arch updates and refresh the feed every minute, you would put this into your {{ic|~/.conkyrc}} in the TEXT section:
+
[https://github.com/orschiro/scriptlets/tree/master/ConkyTimer ConkyTimer] is a simple countdown timer that displays the remaining time of a defined task.
 +
 
 +
Start the timer using {{ic|conkytimer "<task description>" <min>}}.
 +
 
 +
=== Display RSS feeds ===
 +
 
 +
''Conky'' has the ability to display RSS feeds natively without the need for an outside script to run and output into Conky. For example, to display the titles of the ten most recent Planet Arch updates and refresh the feed every minute, you would put this into your {{ic|conky.conf}} in the {{ic|TEXT}} section:
  
 
  ${rss https://planet.archlinux.org/rss20.xml 1 item_titles 10 }
 
  ${rss https://planet.archlinux.org/rss20.xml 1 item_titles 10 }
Line 167: Line 179:
 
where 1 is in minutes the refresh interval (15 mn is default),4 the number of items you wish to show.
 
where 1 is in minutes the refresh interval (15 mn is default),4 the number of items you wish to show.
  
===Display Distrowatch Arch Linux ranking===
+
=== Display rTorrent stats ===
See [https://bbs.archlinux.org/viewtopic.php?id=88779 this thread].
 
  
===Display rTorrent stats===
 
 
See [https://bbs.archlinux.org/viewtopic.php?id=67304 this thread].
 
See [https://bbs.archlinux.org/viewtopic.php?id=67304 this thread].
  
===Display number of new emails (Gmail)===
+
=== Display your WordPress blog stats ===
Create a file named {{ic|gmail.py}} in a convenient location (this example uses {{ic|~/.scripts/}}) with the following [[Python]] code:
+
 
#!/usr/bin/env python
+
This can be achieved by using the in python written extension named [http://evilshit.wordpress.com/2013/04/20/conkypress-a-wordpress-stats-visualization-tool-for-your-desktop/ ConkyPress].
+
 
from urllib.request import FancyURLopener
+
=== Display number of new emails ===
+
==== Gmail ====
username = 'username'
+
If you use 2-factor authentication, you need to use an [https://myaccount.google.com/apppasswords App Password].
password  = 'superlongandhardpassword'
 
 
url = 'https://%s:%s@mail.google.com/mail/feed/atom' % (username, password)
 
 
opener = FancyURLopener()
 
page = opener.open(url)
 
 
contents = page.read().decode('utf-8')
 
 
 
ifrom = contents.index('<fullcount>') + 11
 
ito  = contents.index('</fullcount>')
 
 
unread = contents[ifrom:ito]
 
 
print(unread)
 
  
as suggested [https://bbs.archlinux.org/viewtopic.php?id=130608 here]. A similar change can be made if using a Google App mail account (below).
+
For method 1, 2 and 3:
  
You can also use Python's urllib as follows.
+
Create one of the following files in a convenient location (for example in {{ic|~/.scripts/}}).
import urllib.request
 
from xml.etree import ElementTree as etree
 
 
# Enter your username and password below within quotes below, in place of ****.
 
# Set up authentication for gmail
 
auth_handler = urllib.request.HTTPBasicAuthHandler()
 
auth_handler.add_password(realm='New mail feed',
 
                          uri='https://mail.google.com/',
 
                          user= '****',
 
                          passwd= '****')
 
opener = urllib.request.build_opener(auth_handler)
 
# ...and install it globally so it can be used with urlopen.
 
urllib.request.install_opener(opener)
 
 
gmail = 'https://mail.google.com/gmail/feed/atom'
 
NS = '{http://purl.org/atom/ns#}'
 
with urllib.request.urlopen(gmail) as source:
 
    tree = etree.parse(source)
 
fullcount = tree.find(NS + 'fullcount').text
 
print(fullcount + ' new')
 
  
Add the following string to your {{ic|~/.conkyrc}} in order the check your Gmail account for new email every five minutes (300 seconds) and display:
+
Then add the following string to your {{ic|conky.conf}} in order the check your Gmail account for new email every five minutes (300 seconds) and display:
 
  ${execpi 300 python ~/.scripts/gmail.py}
 
  ${execpi 300 python ~/.scripts/gmail.py}
  
====Other Methods====
+
===== method 1 =====
The same way, but with using {{ic|grep}} and {{ic|sed}} for filtering output of {{ic|wget}}:
+
This script uses retrieves the number of new email via Gmail's Atom API.
 +
{{hc|gmail.py|<nowiki>
 +
#!/usr/bin/env python3
 +
 
 +
import urllib.request
 +
 
 +
email = 'your email'
 +
password = 'your password'
 +
 
 +
# Set up authentication for gmail
 +
auth_handler = urllib.request.HTTPBasicAuthHandler()
 +
auth_handler.add_password(realm='mail.google.com',
 +
                          uri='https://mail.google.com/',
 +
                          user=email,
 +
                          passwd=password)
 +
opener = urllib.request.build_opener(auth_handler)
 +
# ...and install it globally so it can be used with urlopen.
 +
urllib.request.install_opener(opener)
 +
 
 +
gmailurl = 'https://mail.google.com/gmail/feed/atom'
 +
with urllib.request.urlopen(gmailurl) as page:
 +
    contents = page.read().decode('utf-8')
 +
 
 +
ifrom = contents.index('<fullcount>') + 11
 +
ito  = contents.index('</fullcount>')
 +
 
 +
fullcount = contents[ifrom:ito]
 +
 
 +
print('{} new emails'.format(fullcount))
 +
 
 +
</nowiki>}}
 +
 
 +
===== method 2 =====
 +
Same as method 1, but does proper XML parsing.
 +
 
 +
{{hc|gmail.py|<nowiki>
 +
#!/usr/bin/env python3
 +
 
 +
import urllib.request
 +
from xml.etree import ElementTree as etree
 +
 
 +
email = 'your email'
 +
password = 'your password'
 +
 
 +
# Set up authentication for gmail
 +
auth_handler = urllib.request.HTTPBasicAuthHandler()
 +
auth_handler.add_password(realm='mail.google.com',
 +
                          uri='https://mail.google.com/',
 +
                          user=email,
 +
                          passwd=password)
 +
opener = urllib.request.build_opener(auth_handler)
 +
# ...and install it globally so it can be used with urlopen.
 +
urllib.request.install_opener(opener)
 +
 
 +
gmailurl = 'https://mail.google.com/gmail/feed/atom'
 +
NS = '{http://purl.org/atom/ns#}'
 +
with urllib.request.urlopen(gmailurl) as source:
 +
    tree = etree.parse(source)
 +
fullcount = tree.find(NS + 'fullcount').text
 +
 
 +
print('{} new emails'.format(fullcount))
 +
</nowiki>}}
 +
 
 +
===== method 3 =====
 +
 
 +
The same way, but with using {{ic|curl}}, {{ic|grep}} and {{ic|sed}}:
 
   
 
   
$ wget -q -O - https://mail.google.com/a/'''domain'''/feed/atom \
+
{{hc|gmail.sh|
>                                --http-user='''login'''@'''domain''' \
+
#!/usr/bin/sh
>                                --http-password='''password''' \
 
>                                --no-check-certificate | \
 
> grep fullcount | sed 's/<[^0-9]*>//g'
 
  
instead of words '''login, domain, password''' you must type yours data.
+
curl -s -u '''email''':'''password''' <nowiki>https://mail.google.com/mail/feed/atom | grep fullcount | sed 's/<[^0-9]*>//g'</nowiki>
 +
}}
 +
 
 +
replace ''email'' and ''password'' with your data.
 
   
 
   
 +
===== method 4 =====
 +
 
Alternatively, you can use [http://www.stunnel.org/ stunnel] which is provided by the {{Pkg|stunnel}} package.
 
Alternatively, you can use [http://www.stunnel.org/ stunnel] which is provided by the {{Pkg|stunnel}} package.
  
The following configuration is taken from [http://conky.sourceforge.net/faq.html Conky's FAQ]
+
The following configuration is taken from [https://github.com/brndnmtthws/conky/wiki/FAQ Conky's FAQ]
  
Modify {{ic|/etc/stunnel/stunnel.conf}} as follows, and then start the {{ic|stunnel}} [[Daemon|daemon]]:
+
Modify {{ic|/etc/stunnel/stunnel.conf}} as follows, and then [[start]] {{ic|stunnel.service}}:
 
  # Service-level configuration for TLS server
 
  # Service-level configuration for TLS server
 
  [imap]
 
  [imap]
Line 253: Line 294:
 
  connect = imap.gmail.com:993
 
  connect = imap.gmail.com:993
  
The only thing left is our {{ic|~/.conkyrc}}:
+
The only thing left is our {{ic|conky.conf}}:
 
  imap localhost username * -i 120 -p 993
 
  imap localhost username * -i 120 -p 993
 
  TEXT
 
  TEXT
 
  Inbox: ${imap_unseen}/${imap_messages}
 
  Inbox: ${imap_unseen}/${imap_messages}
  
Here I used * as the password for Conky to ask for it at start, but you do not ''have'' to do it.
+
Here I used {{ic|*}} as the password for ''conky'' to ask for it at start, but you do '''not''' have to do it.
  
====Google Apps====
+
==== IMAP + SSL using Perl ====
The above Python script did not work for me and my Google Apps account. I modified the script below to work with a Google App mail account [[Python]] code:
 
import os
 
 
 
#Enter your domain, username and password below within double quotes
 
# eg. domain="yourdomain.com", username="username" and password="password"
 
domain="yourdomain.com"
 
username="username"
 
password="password"
 
com="wget -q -O - https://mail.google.com/a/"+domain+"/feed/atom --http-user="+username+"@"+domain+" --http-password="+password+" --no-check-certificate"
 
temp=os.popen(com)
 
msg=temp.read()
 
index=msg.find("<fullcount>")
 
index2=msg.find("</fullcount>")
 
fc=int(msg[index+11:index2])
 
print(str(fc)+" new")
 
  
===Display new emails (IMAP + SSL)===
+
''Conky'' has built in support for IMAP accounts but does not support SSL. This can be provided using this script from [http://www.unix.com/shell-programming-scripting/115322-perl-conky-gmail-imap-unread-message-count.html this forum post]. This requires the Perl/CPAN Modules Mail::IMAPClient and IO::Socket::SSL which are in the {{AUR|perl-mail-imapclient}} and {{Pkg|perl-io-socket-ssl}} packages
Conky has built in support for IMAP accounts but does not support SSL. This can be provided using this script from [http://www.unix.com/shell-programming-scripting/115322-perl-conky-gmail-imap-unread-message-count.html this forum post]. This requires the Perl/CPAN Modules Mail::IMAPClient and IO::Socket::SSL which are in the {{AUR|perl-mail-imapclient}} and {{Pkg|perl-io-socket-ssl}} packages
 
  
Create a file named {{ic|imap.pl}} in a location to be read by Conky. In this file, add (with the appropriate changes):
+
Create a file named {{ic|imap.pl}} in a location to be read by ''conky'' (for example in {{ic|~/.scripts/}}). In this file, add (with the appropriate changes):
#!/usr/bin/perl
+
{{hc|imap.pl|<nowiki>
+
#!/usr/bin/perl
# gimap.pl by gxmsgx
 
# description: get the count of unread messages on imap
 
 
use strict;
 
use Mail::IMAPClient;
 
use IO::Socket::SSL;
 
 
my $username = 'example.username';
 
my $password = 'password123';
 
 
my $socket = IO::Socket::SSL->new(
 
  PeerAddr => 'imap.server',
 
  PeerPort => 993
 
  )
 
  or die "socket(): $@";
 
 
my $client = Mail::IMAPClient->new(
 
  Socket  => $socket,
 
  User    => $username,
 
  Password => $password,
 
  )
 
  or die "new(): $@";
 
 
if ($client->IsAuthenticated()) {
 
    my $msgct;
 
 
    $client->select("INBOX");
 
    $msgct = $client->unseen_count||'0';
 
    print "$msgct\n";
 
}
 
 
   
 
   
$client->logout();
+
# by gxmsgx
 +
# description: get the count of unread messages on imap
  
Add to {{ic|~/.conkyrc}}:
+
use strict;
${execpi 300 ~/.conky/imap.pl}
+
use Mail::IMAPClient;
or wherever you saved the file.
+
use IO::Socket::SSL;
  
Alternatively, you can use stunnel as shown above: [[Conky#How to display the number of new emails (Gmail) in Conky]]
+
my $username = 'example.username';
 +
my $password = 'password123';
  
== User-contributed configuration examples ==
+
my $socket = IO::Socket::SSL->new(
=== Graysky ===
+
  PeerAddr => 'imap.server',
[[http://img9.imageshack.us/img9/3153/imageffj.jpg Screen shot]]
+
  PeerPort => 993
 +
)
 +
or die "socket(): $@";
 +
 +
my $client = Mail::IMAPClient->new(
 +
  Socket  => $socket,
 +
  User    => $username,
 +
  Password => $password,
 +
)
 +
or die "new(): $@";
 +
 +
if ($client->IsAuthenticated()) {
 +
  my $msgct;
  
[[https://github.com/graysky2/configs/raw/master/dotfiles/.conkyrc Here]] it is - modify to fit your system. Optimized for a quad core chip w/ several hdds (although one of them is not connected for this screenshot) and an nvidia graphics card. You can easily modify this to a dual or single core system with one or whatever number of hdds.
+
  $client->select("INBOX");
 +
  $msgct = $client->unseen_count||'0';
 +
  print "$msgct\n";
 +
}
  
==A sample rings script with nvidia support:==
+
$client->logout();
 +
</nowiki>}}
  
{{bc|1=
+
Add to {{ic|conky.conf}}:
# -- Conky settings -- #
+
${execpi 300 ~/.scripts/imap.pl}
background no
+
or wherever you saved the file.
update_interval 1
 
  
cpu_avg_samples 2
+
If you use Gmail you might need to [http://www.google.com/accounts/IssuedAuthSubTokens?hide_authsub=1 generate] an application specific password.
net_avg_samples 2
 
  
override_utf8_locale yes
+
Alternatively, you can use stunnel as shown above: [[#Gmail]]
  
double_buffer yes
+
==== IMAP using PHP ====
no_buffers yes
+
Another alternative using PHP. PHP needs to be installed and {{ic|1=extension=imap.so}} must be uncommented in {{ic|/etc/php/php.ini}}.
  
text_buffer_size 2048
+
Then create a file named {{ic|imap.php}} in a location to be read by ''conky'' (for example in {{ic|~/.scripts/}}). Make the file executable:
imlib_cache_size 0
+
$ chmod +x imap.php
  
# -- Window specifications -- #
+
In this file, add (with the appropriate changes):
  
own_window yes
+
{{hc|imap.php|<nowiki>
own_window_type normal
+
#!/usr/bin/php
own_window_transparent yes
+
<?php
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
+
// See http://php.net/manual/function.imap-open.php for more information about
 +
// the mailbox string in the first parameter of imap_open.
 +
// This example is ready to use with Office 365 Exchange Mails,
 +
// just replace your username (=email address) and the password.
 +
$mbox = imap_open("{outlook.office365.com:993/imap/ssl/novalidate-cert}", "username", "password");
  
border_inner_margin 0
+
// Total number of emails
border_outer_margin 0
+
$nrTotal = imap_num_msg($mbox);
 +
 +
// Number of unseen emails. There are other ways using imap_status to count
 +
// unseen messages, but they don't work with Office 365 Exchange. This one does.
 +
$unseen = imap_search($mbox, 'UNSEEN');
 +
$nrUnseen = $unseen ? count($unseen) : 0;
 +
 +
// Display the result, format as you like.
 +
echo $nrUnseen.'/'.$nrTotal;
 +
 +
// Not needed, because the connection is closed after the script end.
 +
// For the sake of clean public available scripts, we are nice to
 +
// the imap server and close the connection manually.
 +
imap_close($mbox);
 +
</nowiki>}}
  
minimum_size 320 800
+
Add to {{ic|conky.conf}}:
maximum_width 320
 
  
alignment bottom_right
+
${execpi 300 ~/.scripts/imap.php}
gap_x 0
 
gap_y 0
 
  
# -- Graphics settings -- #
+
or wherever you saved the file.
draw_shades no
 
draw_outline no
 
draw_borders no
 
draw_graph_borders yes
 
  
# -- Text settings -- #
+
This script displays A/B where A is the number of unseen emails and B is the total number of mails in the mailbox. There are a lot of other informations available through a lot of PHP functions like with imap_Status (http://php.net/manual/function.imap-status.php). Just see the PHP docs about IMAP: http://php.net/manual/ref.imap.php.
use_xft yes
 
xftfont MaiandraGD:size=24
 
xftalpha 0.4
 
  
uppercase no
+
=== Show graphic of active network interface ===
  
default_color 888888
+
To test if a network inferface is currently active, you can use the test conky variable {{ic | if_existing}} on the {{ic | operstate}} of the interface. Here's an example for wlo1 :
  
# -- Lua Load -- #
+
{{bc |draw_graph_borders yes
lua_load ~/conky/lua/lua.lua
+
${if_existing /sys/class/net/wlo1/operstate up}
lua_draw_hook_pre ring_stats
+
${color #0077ff}Net Down:$color ${downspeed wlo1}      ${color #0077ff}Net Up:$color ${upspeed wlo1}
 +
${color #0077ff}${downspeedgraph wlo1 32,155 104E8B 0077ff} $alignr${color #0077ff}${upspeedgraph wlo1 32,155 104E8B 0077ff}
 +
${endif}
 +
}}
  
TEXT
+
This is the expected result :
${alignr}${voffset 53}${goto 90}${font MaiandraGD:size=11}${time %A, %d %B %Y}
 
  
 +
http://i.imgur.com/pQQbsP6.png
  
${voffset 5}${goto 164}${font MaiandraGD:size=16}${time %H:%M}
+
=== Fix scrolling with UTF-8 multibyte characters ===
  
 +
The current version of ''conky'' (1.9.0) suffers from a [https://github.com/brndnmtthws/conky/issues/129 bug] where scrolling text increments by byte, not by character, resulting in text containing multibyte characters to disappear and reappear while scrolling.  A package with a patch fixing this bug can be found in the AUR: {{AUR|conky-utfscroll}}
  
 +
== User-contributed configuration examples ==
  
${voffset -40}${goto 100}${font MaiandraGD:size=9}Kernel:${offset 70}Uptime:
+
=== A sample rings script with nvidia support===
${goto 90}${font MaiandraGD:size=9}$kernel${offset 40}$uptime
 
${voffset 57}${goto 117}${font snap:size=8}${cpu cpu0}%
 
${goto 117}${cpu cpu1}%
 
${goto 117}CPU
 
${voffset 19}${goto 145}${memperc}%
 
${goto 145}$swapperc%
 
${goto 145}MEM
 
${voffset 25}${goto 170}${nvidia gpufreq}
 
${goto 170}${nvidia memfreq}
 
${goto 170}GPU
 
${voffset 27}${goto 198}${totaldown ppp0}
 
${goto 198}${totalup ppp0}
 
${goto 205}NET
 
${voffset 21}
 
${goto 222}${fs_used /home}
 
${goto 230}DISK
 
}}
 
  
*And the required lua.lua script:
+
See [https://gist.github.com/anonymous/85d052c0c23e58bc3666].
  
{{bc|1=
+
== A note about symbolic fonts ==
--[[
 
Ring Meters by londonali1010 (2009)
 
  
This script draws percentage meters as rings. It is fully customisable; all options are described in the script.
+
Many of the more decorated {{ic|conky.conf}}'s use the fonts PizzaDude Bullets and Pie Charts for Maps. They are available from the AUR as {{AUR|ttf-pizzadude-bullets}} and {{AUR|ttf-piechartsformaps}}{{Broken package link|{{aur-mirror|ttf-piechartsformaps}}}} respectively, or they can be found and downloaded with a quick search and manually installed using the instructions in [[Fonts]].
  
IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement on line 145 uses a delay to make sure that this does not happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num > 5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num > 3; conversely if you update Conky every 0.5s, you should use update_num > 10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.
+
== Universal method to enable true transparency ==
  
To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
+
Transparency is a strange beast in ''conky'', but there is a way to universally apply true transparency with any environment or window manager by using ''xcompmgr'' and ''transset-df''. [[Pacman#Installing specific packages|Install]] {{Pkg|xcompmgr}} and {{Pkg|transset-df}}.
        lua_load ~/scripts/rings-v1.2.1.lua
 
        lua_draw_hook_pre ring_stats
 
 
 
Changelog:
 
+ v1.2.1 -- Fixed minor bug that caused script to crash if conky_parse() returns a nil value (20.10.2009)
 
+ v1.2 -- Added option for the ending angle of the rings (07.10.2009)
 
+ v1.1 -- Added options for the starting angle of the rings, and added the "max" variable, to allow for variables that output a numerical value rather than a percentage (29.09.2009)
 
+ v1.0 -- Original release (28.09.2009)
 
]]
 
 
settings_table = {
 
        {
 
                -- Edit this table to customise your rings.
 
                -- You can create more rings simply by adding more elements to settings_table.
 
                -- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
 
                name='time',
 
                -- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''.
 
                arg='%I.%M',
 
                -- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
 
                max=12,
 
                -- "bg_colour" is the colour of the base ring.
 
                bg_colour=0x888888,
 
                -- "bg_alpha" is the alpha value of the base ring.
 
                bg_alpha=0.3,
 
                -- "fg_colour" is the colour of the indicator part of the ring.
 
                fg_colour=0x888888,
 
                -- "fg_alpha" is the alpha value of the indicator part of the ring.
 
                fg_alpha=0.5,
 
                -- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
 
                x=191, y=145,
 
                -- "radius" is the radius of the ring.
 
                radius=32,
 
                -- "thickness" is the thickness of the ring, centred around the radius.
 
                thickness=4,
 
                -- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
 
                start_angle=0,
 
                -- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger (e.g. more clockwise) than start_angle.
 
                end_angle=360
 
        },
 
        {
 
                name='time',
 
                arg='%M.%S',
 
                max=60,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=191, y=145,
 
                radius=37,
 
                thickness=4,
 
                start_angle=0,
 
                end_angle=360
 
        },
 
        {
 
                name='time',
 
                arg='%S',
 
                max=60,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=191, y=145,
 
                radius=42,
 
                thickness=4,
 
                start_angle=0,
 
                end_angle=360
 
        },
 
        {
 
                name='cpu',
 
                arg='cpu0',
 
                max=100,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=140, y=300,
 
                radius=26,
 
                thickness=5,
 
                start_angle=-90,
 
                end_angle=180
 
        },
 
        {
 
                name='cpu',
 
                arg='cpu1',
 
                max=100,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=140, y=300,
 
                radius=20,
 
                thickness=5,
 
                start_angle=-90,
 
                end_angle=180
 
        },
 
        {
 
                name='memperc',
 
                arg='',
 
                max=100,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=170, y=350,
 
                radius=26,
 
                thickness=5,
 
                start_angle=-90,
 
                end_angle=180
 
        },
 
        {
 
                name='swapperc',
 
                arg='',
 
                max=100,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=170, y=350,
 
                radius=20,
 
                thickness=5,
 
                start_angle=-90,
 
                end_angle=180
 
        },
 
        {
 
                name='time',
 
                arg='%d',
 
                max=31,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=191, y=145,
 
                radius=50,
 
                thickness=5,
 
                start_angle=-140,
 
                end_angle=-30
 
        },
 
        {
 
                name='time',
 
                arg='%m',
 
                max=12,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=191, y=145,
 
                radius=50,
 
                thickness=5,
 
                start_angle=30,
 
                end_angle=140
 
        },
 
--      {
 
--              name='fs_used_perc',
 
--              arg='/',
 
--              max=100,
 
--              bg_colour=0x888888,
 
--              bg_alpha=0.3,
 
--              fg_colour=0x888888,
 
--              fg_alpha=0.5,
 
--              x=260, y=503,
 
--              radius=26,
 
--              thickness=5,
 
--              start_angle=-90,
 
--              end_angle=180
 
--      },
 
        {
 
                name='fs_used_perc',
 
                arg='/home',
 
                max=100,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=260, y=503,
 
                radius=20,
 
                thickness=5,
 
                start_angle=-90,
 
                end_angle=180
 
        },
 
        {
 
                name='totalup',
 
                arg='ppp0',
 
                max=2,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=230, y=452,
 
                radius=20,
 
                thickness=5,
 
                start_angle=-90,
 
                end_angle=180
 
        },
 
        {
 
                name='totaldown',
 
                arg='ppp0',
 
                max=2,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=230, y=452,
 
                radius=26,
 
                thickness=5,
 
                start_angle=-90,
 
                end_angle=180
 
        },
 
        {
 
                name='nvidia',
 
                arg='gpufreq',
 
                max=475,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=200, y=401,
 
                radius=26,
 
                thickness=5,
 
                start_angle=-90,
 
                end_angle=180
 
        },
 
{
 
                name='nvidia',
 
                arg='memfreq',
 
                max=700,
 
                bg_colour=0x888888,
 
                bg_alpha=0.3,
 
                fg_colour=0x888888,
 
                fg_alpha=0.5,
 
                x=200, y=401,
 
                radius=20,
 
                thickness=5,
 
                start_angle=-90,
 
                end_angle=180
 
        },
 
}
 
 
require 'cairo'
 
 
function rgb_to_r_g_b(colour,alpha)
 
        return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
 
end
 
 
function draw_ring(cr,t,pt)
 
        local w,h=conky_window.width,conky_window.height
 
 
        local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
 
        local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']
 
 
        local angle_0=sa*(2*math.pi/360)-math.pi/2
 
        local angle_f=ea*(2*math.pi/360)-math.pi/2
 
        local t_arc=t*(angle_f-angle_0)
 
 
        -- Draw background ring
 
 
        cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
 
        cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
 
        cairo_set_line_width(cr,ring_w)
 
        cairo_stroke(cr)
 
 
        -- Draw indicator ring
 
 
        cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
 
        cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
 
        cairo_stroke(cr)
 
end
 
 
function conky_ring_stats()
 
        local function setup_rings(cr,pt)
 
                local str=''
 
                local value=0
 
 
                str=string.format('${%s %s}',pt['name'],pt['arg'])
 
                str=conky_parse(str)
 
 
                value=tonumber(str)
 
                if value == nil then value = 0 end
 
                pct=value/pt['max']
 
 
                draw_ring(cr,pct,p<nowiki><nowiki>Insert non-formatted text here</nowiki>'''Bold text'''</nowiki>t)
 
        end
 
 
        if conky_window==nil then return end
 
        local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_w    indow.height)
 
 
        local cr=cairo_create(cs)
 
 
        local updates=conky_parse('${updates}')
 
        update_num=tonumber(updates)
 
 
        if update_num>5 then
 
                for i in pairs(settings_table) do
 
                        setup_rings(cr,settings_table[i])
 
                end
 
        end
 
end           
 
}}
 
 
 
== A note about symbolic fonts ==
 
  
Many of the more decorated .conkyrc's use the fonts PizzaDude Bullets and Pie Charts for Maps. They are available from the AUR as 'ttf-pizzadude-bullets' and 'ttf-piechartsformaps' respectively, or they can be found and downloaded with a quick search and manually installed using the instructions in [[Fonts]].
+
{{Note|This may conflict with any other compositing manager you are already using.}}
  
== Fonts appear smaller than they should ==
+
Check ''xcompmgr'' documentation to help you decide which compositing options you would like to enable. The following is a common standard command.
If you notice that your conky fonts appear smaller than they should, or they don't align properly, it could be caused by a default setting in the infinality freetype2 patch.  This setting can cause some programs to display fonts at 72 DPI instead of 96 even if the rest of your system is set to 96. If you notice a problem open {{ic|/etc/fonts/infinality/infinality.conf}}  search for the section on DPI and change 72 to 96.
 
  
== Universal method to enable true transparency ==
+
$ xcompmgr -c -t-5 -l-5 -r4.2 -o.55 &
  
Transparency is a strange beast in Conky, but there is a way to universally apply true transparency with any environment or window manager by using xcompmgr and transset-df. Install xcompmgr from [extra] and transset-df from [community] with {{ic|pacman -S xcompmgr transset-df}}. These packages both have the same 3 dependencies, so this is the lightest method for composition available, for those of you using standalone window managers in order to achieve the leanest setup you can manage (or whatever reason you have :D)
+
Make sure ''conky'' is running with {{ic|conky &}}. Use ''transset-df'' to enable transparency on the ''conky'' window. Set '.5' to any value in the range 0 - 1.
  
NOTE: This may conflict with any other compositing manager you are already using.
+
$ transset-df .5 -n Conky
  
Check xcompmgr documentation to help you decide which compositing options you would like to enable. The following is a common standard command.
+
This should give your ''conky'' window true transparency. If you get an error like:
  
{{bc|
+
No Window matching Conky exists!
xcompmgr -c -t-5 -l-5 -r4.2 -o.55 &
 
}}
 
  
Make sure conky is running with {{ic|conky &}}. Use transset-df to enable transparency on the Conky window. Set '.5' to any value in the range 0 - 1.
+
verify that ''conky'' is running, and use ''xprop'' and click on the ''conky'' window to find the name you should pass to {{ic|transset-df}}.
  
{{bc|
+
{{hc|$ xprop &#124; grep WM_NAME|2=WM_NAME(STRING) = "Conky (ArchitectLinux)"}}
transset-df .5 -n Conky
 
}}
 
  
This should give your conky window true transparency. If you get an error like,
+
In this case, ''conky'' is right, but for you it may be different, so be sure to use your output instead. If {{ic|conky.conf}} has an option {{ic|own_window_type}} set to {{ic|panel}}, then this ''xprop'' invocation may show no output. Try using {{ic|dock}}, {{ic|normal}}, {{ic|override}} or {{ic|desktop}} instead.
{{hc|$ transset-df .5 -n Conky|No Window matching Conky exists!}}
 
Verify that conky is running, and use xprop and click on the conky window to find the name you should pass to {{ic|transset-df}}.
 
{{hc|$ xprop &#124; grep WM_NAME|2=WM_NAME(STRING) = "Conky (ArchitectLinux)"}}
 
  
In this case, "Conky" is right, but for you it may be different, so be sure to use your output instead. If ~/.conkyrc has {{ic|own_window_type panel}} then this xprop invocation may show now output. Try using any of the following options instead. {{ic|<nowiki>own_window_type {dock,normal,override,desktop}</nowiki>}}
+
Use this in {{ic|~/.xinitrc}} to have transparent ''conky'' after [[X]] starts up:
  
Use this in ~/.xinitrc to have transparent conky run when you {{ic|startx}}.
+
xcompmgr -c -t-5 -l-5 -r4.2 -o.55 &
 +
conky -d; sleep 1 && transset-df .5 -n Conky
  
{{bc|
+
== See also ==
xcompmgr -c -t-5 -l-5 -r4.2 -o.55 &
 
conky -d; sleep 1 && transset-df .5 -n Conky
 
}}
 
  
== External links ==
+
* [https://github.com/brndnmtthws/conky Official website]
*[https://bbs.archlinux.org/viewtopic.php?id=39906 Conky Configs on arch forums]
+
* [http://conky.sourceforge.net/config_settings.html Official Conky variables for configuration]
*[http://conky.sourceforge.net/ Official website]
+
* [http://conky.sourceforge.net/variables.html Official Conky objects]
*[http://freshmeat.net/projects/conky/ Conky] on [[wikipedia:Freshmeat|Freshmeat]]
+
* [https://bbs.archlinux.org/viewtopic.php?id=39906 Conky Configs on arch forums]
*[http://sourceforge.net/projects/conky/ Conky] on [[wikipedia:sourceforge.net|SourceForge]]
+
* [http://freecode.com/projects/conky/ Conky] on [[wikipedia:Freecode|Freecode]]
*[irc://chat.freenode.org/conky #conky] IRC chat channel on [[wikipedia:Freenode|freenode]]
+
* [irc://chat.freenode.org/conky #conky] IRC chat channel on [[wikipedia:Freenode|freenode]]
*[http://novel.evilcoder.org/wiki/index.php?title=ConkyFAQ&oldid=12463 FAQ]
+
* [http://novel.evilcoder.org/wiki/index.php?title=ConkyFAQ&oldid=12463 FAQ]

Latest revision as of 14:23, 27 August 2017

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: Lots of useless config dumps and unneeded complexity (Discuss in Talk:Conky#)

Conky is a system monitor software for the X Window System. It is available for GNU/Linux and FreeBSD. It is free software released under the terms of the GPL license. Conky is able to monitor many system variables including CPU, memory, swap, disk space, temperature, top, upload, download, system messages, and much more. It is extremely configurable, however, the configuration can be a little hard to understand. Conky is a fork of torsmo.

Installation and configuration

Install the conky package. For alternative packages with more features, see #AUR packages.

Create a local configuration file:

$ mkdir -p ~/.config/conky
$ conky -C > ~/.config/conky/conky.conf

Now you can edit ~/.config/conky/conky.conf to customize conky as you wish. For a few example configuration files, see this page.

When editing your config file, you will see immediately the effect of any change as soon as you save it. There is no need to log out/log in your X session. So best is to test all kind of options, one by one, save the configuration file and see the change on your conky window, and correct if your change is inappropriate.

One of the nice features of conky is to pipe to your desktop some /var/log/ files to read all kinds of log messages. Most of these files can only be read by root, but running conky as root is not recommended, so you will need to add username to the log group:

# usermod -aG log username

AUR packages

In addition to the basic conky package, there are various AUR packages available with extra compile options enabled:

  • conky-cliConky without X11 dependencies
|| conky-cliAUR
  • conky-luaConky with Lua support
|| conky-luaAUR
  • conky-lua-nvConky with both Lua and Nvidia support
|| conky-lua-nvAUR
  • conky-nvidiaConky with Nvidia support
|| conky-nvidiaAUR

Tips and tricks

Config file syntax changed

Since Conky 1.10, configuration files have been written with Lua syntax, like so:

 conky.config = {
   -- Comments start with a double dash
   bool_value = true,
   string_value = 'foo',
   int_value = 42,
 }
 conky.text = [[
 $variable
 ${evaluated variable}
 ]]

Some examples below may still use the old syntax, which looks like this:

 bool_value yes
 string_value 'foo'
 int_value 42

A Lua script is available to convert from the old syntax to the new Lua syntax here.

If in doubt, or something doesn't work at all, you can start with the default config file:

 $ conky -C > conky.conf.default

Enable real transparency

To enable real transparency, add this line to conky.conf:

own_window_transparent = true,

The above option is not desired with the own_window_argb_visual = true option.

If transparency doesn't work you might need to follow #Universal method to enable true transparency.

Note: Xfce requires enabled compositing, see [1].

Autostart

In conky.conf file:

background = true,

This variable will fork conky to your background. If you want to make your window always visible on your desktop, sticky across all workspaces and not showing in your taskbar, add these arguments:

own_window = true,
own_window_type = 'override',

The override takes conky out of the control of your window manager.

Add a ~/.config/autostart/conky.desktop:

conky.desktop
[Desktop Entry]
Type=Application
Name=conky
Exec=conky -d
StartupNotify=false
Terminal=false

You may want to add -p 10 to the Exec parameter so that it starts drawing conky after the desktop is up (-p 10 means pause for 10 seconds at startup before doing anything).

Prevent flickering

Conky needs Double Buffer Extension (DBE) support from the X server to prevent flickering because it cannot update the window fast enough without it. It can be enabled in /etc/X11/xorg.conf with Load "dbe" line in "Module" section. The xorg.conf file has been replaced (1.8.x patch upwards) by /etc/X11/xorg.conf.d which contains the particular configuration files. DBE is loaded automatically.

To enable double buffering, add the option

 double_buffer = true,

to your conky.conf.

Custom colors

Aside the classic preset colors (white, black, yellow...), you can set your own custom color using the color name code. To determine the code of a color, use a color selector app. The basic gcolor2 package in the official repositories will give you the color name. It is made of six hexadecimal digits (0-9, A-F). Add this line in your configuration file for a custom color:

 color0 = 'white', --convention for standard named colors
 color1 = '00CC00', --convention for hex colors: no pound sign

Then, when editing the TEXT section, use custom color number previously defined, for example ${color3} .

Dual Screen

When using a dual screen configuration, you will need to play with two options to place your conky window. Let's say you are running a 1680X1050 pixels resolution, and you want the window on middle top of your left monitor, you will use this:

alignment = 'top_left',
gap_X = 840,

The alignment option is trivial, and gap_X option is the distance, in pixels, from the left border of your screen.

The xinerama_head option might also need to be set.

Do not minimize on Show Desktop

Using Compiz: If the 'Show Desktop' button or key-binding minimizes Conky along with all other windows, start the Compiz configuration settings manager, go to "General Options" and uncheck the "Hide Skip Taskbar Windows" option.

If you do not use Compiz, try editing conky.conf and adding/changing the following line:

own_window_type = 'override',

or

own_window_type = 'desktop',

Refer to conkys man page for the exact differences. But the latter option enables you to snap windows to conkys border using resize key-binds in e.g. Openbox, which the first one does not.

Integrate with GNOME Shell

Some have experienced problems with conky showing up under GNOME.

Add these lines to conky.conf:

own_window = true,
own_window_type = 'desktop',

For transparency, also add these:

own_window_transparent = true,
own_window_argb_visual = true,
own_window_argb_value = 255,

Display package update information

Pacman provides its own script called checkupdates which displays package updates from the official repos. Use ${execpi 3600 checkupdates | wc -l} to display the total number of packages.

Display weather forecast

See this thread.

Display a countdown timer

ConkyTimer is a simple countdown timer that displays the remaining time of a defined task.

Start the timer using conkytimer "<task description>" <min>.

Display RSS feeds

Conky has the ability to display RSS feeds natively without the need for an outside script to run and output into Conky. For example, to display the titles of the ten most recent Planet Arch updates and refresh the feed every minute, you would put this into your conky.conf in the TEXT section:

${rss https://planet.archlinux.org/rss20.xml 1 item_titles 10 }

If you want to display Arch Forum rss feed, add this line:

${rss https://bbs.archlinux.org/extern.php?action=feed&type=rss 1 item_titles 4}

where 1 is in minutes the refresh interval (15 mn is default),4 the number of items you wish to show.

Display rTorrent stats

See this thread.

Display your WordPress blog stats

This can be achieved by using the in python written extension named ConkyPress.

Display number of new emails

Gmail

If you use 2-factor authentication, you need to use an App Password.

For method 1, 2 and 3:

Create one of the following files in a convenient location (for example in ~/.scripts/).

Then add the following string to your conky.conf in order the check your Gmail account for new email every five minutes (300 seconds) and display:

${execpi 300 python ~/.scripts/gmail.py}
method 1

This script uses retrieves the number of new email via Gmail's Atom API.

gmail.py
#!/usr/bin/env python3

import urllib.request

email = 'your email'
password = 'your password'

# Set up authentication for gmail
auth_handler = urllib.request.HTTPBasicAuthHandler()
auth_handler.add_password(realm='mail.google.com',
                          uri='https://mail.google.com/',
                          user=email,
                          passwd=password)
opener = urllib.request.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib.request.install_opener(opener)

gmailurl = 'https://mail.google.com/gmail/feed/atom'
with urllib.request.urlopen(gmailurl) as page:
    contents = page.read().decode('utf-8')

ifrom = contents.index('<fullcount>') + 11
ito   = contents.index('</fullcount>')

fullcount = contents[ifrom:ito]

print('{} new emails'.format(fullcount))

method 2

Same as method 1, but does proper XML parsing.

gmail.py
#!/usr/bin/env python3

import urllib.request
from xml.etree import ElementTree as etree

email = 'your email'
password = 'your password'

# Set up authentication for gmail
auth_handler = urllib.request.HTTPBasicAuthHandler()
auth_handler.add_password(realm='mail.google.com',
                          uri='https://mail.google.com/',
                          user=email,
                          passwd=password)
opener = urllib.request.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib.request.install_opener(opener)

gmailurl = 'https://mail.google.com/gmail/feed/atom'
NS = '{http://purl.org/atom/ns#}'
with urllib.request.urlopen(gmailurl) as source:
    tree = etree.parse(source)
fullcount = tree.find(NS + 'fullcount').text

print('{} new emails'.format(fullcount))
method 3

The same way, but with using curl, grep and sed:

gmail.sh
#!/usr/bin/sh

curl -s -u email:password https://mail.google.com/mail/feed/atom | grep fullcount | sed 's/<[^0-9]*>//g'

replace email and password with your data.

method 4

Alternatively, you can use stunnel which is provided by the stunnel package.

The following configuration is taken from Conky's FAQ

Modify /etc/stunnel/stunnel.conf as follows, and then start stunnel.service:

# Service-level configuration for TLS server
[imap]
client = yes
accept  = 143
connect = imap.gmail.com:143
protocol = imap
sslVersion = TLSv1
# Service-level configuration for SSL server
[imaps]
client = yes
accept  = 993
connect = imap.gmail.com:993

The only thing left is our conky.conf:

imap localhost username * -i 120 -p 993
TEXT
Inbox: ${imap_unseen}/${imap_messages}

Here I used * as the password for conky to ask for it at start, but you do not have to do it.

IMAP + SSL using Perl

Conky has built in support for IMAP accounts but does not support SSL. This can be provided using this script from this forum post. This requires the Perl/CPAN Modules Mail::IMAPClient and IO::Socket::SSL which are in the perl-mail-imapclientAUR and perl-io-socket-ssl packages

Create a file named imap.pl in a location to be read by conky (for example in ~/.scripts/). In this file, add (with the appropriate changes):

imap.pl
#!/usr/bin/perl
 
# by gxmsgx
# description: get the count of unread messages on imap

use strict;
use Mail::IMAPClient;
use IO::Socket::SSL;

my $username = 'example.username'; 
my $password = 'password123'; 

my $socket = IO::Socket::SSL->new(
  PeerAddr => 'imap.server',
  PeerPort => 993
 )
 or die "socket(): $@";
 
my $client = Mail::IMAPClient->new(
  Socket   => $socket,
  User     => $username,
  Password => $password,
 )
 or die "new(): $@";
 
if ($client->IsAuthenticated()) {
  my $msgct;

  $client->select("INBOX");
  $msgct = $client->unseen_count||'0';
  print "$msgct\n";
}

$client->logout();

Add to conky.conf:

${execpi 300 ~/.scripts/imap.pl} 

or wherever you saved the file.

If you use Gmail you might need to generate an application specific password.

Alternatively, you can use stunnel as shown above: #Gmail

IMAP using PHP

Another alternative using PHP. PHP needs to be installed and extension=imap.so must be uncommented in /etc/php/php.ini.

Then create a file named imap.php in a location to be read by conky (for example in ~/.scripts/). Make the file executable:

$ chmod +x imap.php

In this file, add (with the appropriate changes):

imap.php
#!/usr/bin/php
<?php
// See http://php.net/manual/function.imap-open.php for more information about
// the mailbox string in the first parameter of imap_open.
// This example is ready to use with Office 365 Exchange Mails,
// just replace your username (=email address) and the password.
$mbox = imap_open("{outlook.office365.com:993/imap/ssl/novalidate-cert}", "username", "password");

// Total number of emails
$nrTotal = imap_num_msg($mbox);
 
// Number of unseen emails. There are other ways using imap_status to count
// unseen messages, but they don't work with Office 365 Exchange. This one does.
$unseen = imap_search($mbox, 'UNSEEN');
$nrUnseen = $unseen ? count($unseen) : 0;
 
// Display the result, format as you like.
echo $nrUnseen.'/'.$nrTotal;
 
// Not needed, because the connection is closed after the script end.
// For the sake of clean public available scripts, we are nice to
// the imap server and close the connection manually.
imap_close($mbox);

Add to conky.conf:

${execpi 300 ~/.scripts/imap.php} 

or wherever you saved the file.

This script displays A/B where A is the number of unseen emails and B is the total number of mails in the mailbox. There are a lot of other informations available through a lot of PHP functions like with imap_Status (http://php.net/manual/function.imap-status.php). Just see the PHP docs about IMAP: http://php.net/manual/ref.imap.php.

Show graphic of active network interface

To test if a network inferface is currently active, you can use the test conky variable if_existing on the operstate of the interface. Here's an example for wlo1 :

draw_graph_borders yes 
${if_existing /sys/class/net/wlo1/operstate up}
${color #0077ff}Net Down:$color ${downspeed wlo1}      ${color #0077ff}Net Up:$color ${upspeed wlo1}
${color #0077ff}${downspeedgraph wlo1 32,155 104E8B 0077ff} $alignr${color #0077ff}${upspeedgraph wlo1 32,155 104E8B 0077ff}
${endif}

This is the expected result :

http://i.imgur.com/pQQbsP6.png

Fix scrolling with UTF-8 multibyte characters

The current version of conky (1.9.0) suffers from a bug where scrolling text increments by byte, not by character, resulting in text containing multibyte characters to disappear and reappear while scrolling. A package with a patch fixing this bug can be found in the AUR: conky-utfscrollAUR

User-contributed configuration examples

A sample rings script with nvidia support

See [2].

A note about symbolic fonts

Many of the more decorated conky.conf's use the fonts PizzaDude Bullets and Pie Charts for Maps. They are available from the AUR as ttf-pizzadude-bulletsAUR and ttf-piechartsformapsAUR[broken link: archived in aur-mirror] respectively, or they can be found and downloaded with a quick search and manually installed using the instructions in Fonts.

Universal method to enable true transparency

Transparency is a strange beast in conky, but there is a way to universally apply true transparency with any environment or window manager by using xcompmgr and transset-df. Install xcompmgr and transset-df.

Note: This may conflict with any other compositing manager you are already using.

Check xcompmgr documentation to help you decide which compositing options you would like to enable. The following is a common standard command.

$ xcompmgr -c -t-5 -l-5 -r4.2 -o.55 &

Make sure conky is running with conky &. Use transset-df to enable transparency on the conky window. Set '.5' to any value in the range 0 - 1.

$ transset-df .5 -n Conky

This should give your conky window true transparency. If you get an error like:

No Window matching Conky exists!

verify that conky is running, and use xprop and click on the conky window to find the name you should pass to transset-df.

$ xprop | grep WM_NAME
WM_NAME(STRING) = "Conky (ArchitectLinux)"

In this case, conky is right, but for you it may be different, so be sure to use your output instead. If conky.conf has an option own_window_type set to panel, then this xprop invocation may show no output. Try using dock, normal, override or desktop instead.

Use this in ~/.xinitrc to have transparent conky after X starts up:

xcompmgr -c -t-5 -l-5 -r4.2 -o.55 &
conky -d; sleep 1 && transset-df .5 -n Conky

See also