Outils pour utilisateurs

Outils du site


issue98:tutoriel_conky

If you are like me, you have a lot to do and sometimes forget when something needs to be done. A couple of years ago, I wrote an article about using remind, but I have changed my setup enough that I thought a follow-up article might be worthwhile. There are many ways to keep track of tasks, this is how I am keeping organized – at the moment. This solution will give you a chronological list of things you want to remember, sorted by due date. The list will also tell you how long until each item is due. The time is updated automatically and the list shows up on your desktop. If this sounds interesting keep reading. Below is a shot of my list, which sits in the corner of my desktop. The required programs are: • remind • conky

Si vous êtes comme moi, vous avez plein de choses à faire et, parfois, vous oubliez la date à laquelle il faut faire un truc précis.

Il y a environ deux ans, j'ai écrit un article au sujet de l'utilisation de remind, mais, depuis, j'ai modifié ma configuration au point où je pensais qu'un deuxième article pourrait valoir le coup. Il y a beaucoup de moyens pour suivre vos tâches et voici comment je reste organisé, pour le moment.

Cette solution vous affichera une liste chronologique de choses dont vous voulez vous souvenir, triées par échéance. La liste vous dira aussi combien de temps il reste jusqu'à la date butoir. Le temps est mis à jour automatiquement et la liste s'affiche sur votre bureau. Si cela semble intéressant, continuez votre lecture.

En bas à gauche, vous voyez une capture d'écran de ma liste, qui se trouve dans le coin de mon bureau. [Ndt : « Countdown » = compte à rebours.]

Remind is an ultra geeky calendar program that was written by David Skoll. Remind can do almost anything related to dates. It reads the information stored in a reminders' file which is just a text file with reminders written in a format that remind can understand. The first part of the reminders' file is critical. The file I use has the text shown above at the top. Looking at this, you can see that the first line is an include, which tells remind to include a list of holidays I have in another file. This lets remind include this other file in the list of events/dates it will track for you. The helper functions are what tell remind how to count the minutes, hours and days. The main function is the code that enables remind to give the specific days, hours and minutes left until an event. This is everything inside the parentheses in the scrot (SCReen-shOT). REM 2015-04-11 +30 AT 13:00 MSG Minecraft Party %b (in [_countdown(trigdatetime()-current())])

Écrit par David Skoll, remind est un programme ultra-geeky de calendrier. Remind sait faire tout et n'importe quoi, ou presque, qui a un rapport avec des dates. Il lit les informations stockées dans un fichier de rappel qui n'est qu'un fichier texte contenant des rappels dans un format compréhensible par remind.

La première partie du fichier des rappels est capitale. Le fichier que j'utilise comporte le texte montré ci-dessus.

En l'examinant, vous pouvez voir que la première ligne est un « include », qui dit à remind d'inclure une liste de jours fériés (holidays) que j'ai dans un autre fichier. Ceci permet à remind d'inclure cet autre fichier dans la liste des événements/dates qu'il suivra à votre place. Les fonctions « helper » (assistant) disent à remind comment compter les minutes, les heures et les jours. La « main function » (fonction principale) est le code qui permet à remind d'afficher le nombre exact de jours, heures et minutes restants avant un événement. C'est tout ce qu'il y a à l'intérieur des parenthèses dans le scrot (SCReen-shOT ou capture d'écran).

REM 2015-04-11 +30 AT 13:00 MSG Minecraft Party %b (in [_countdown(trigdatetime()-current())])

This is an example of a reminder in the format that is required for remind to be able to understand an event. The format begins with REM followed by the date and then how many days in advance you want this reminder to be displayed. In this case, I want to start being reminded 30 days in advance. The AT tells remind what time the event will begin. This is followed by MSG and the actual message you want to see. The ending %b tells remind to end with “in x days' time” and the code in the parentheses gives the exact breakdown of how much time is left. In the scrot above, you can see that there was two days' time until my kids' Minecraft party, specifically the party was in 1 day 22 hours and 53 minutes. You could type out each new reminder or use snippets to speed up the process, but I found that to be too much work. So I wrote a very simple script (shown below) to make it easier. Basically, this script asks the user a few questions and then formats the answers into the remind format and adds the new reminder to the reminders' file.

Ceci vous montre un exemple de rappel dans le format nécessaire pour que remind puisse comprendre un événement.

La ligne commence par REM suivi de la date, puis de combien de jours à l'avance il faut que ce rappel soit affiché. Dans ce cas, je veux que le rappel démarre 30 jours avant l'événement. AT indique à remind l'heure à laquelle l'événement commencera. Ensuite vient MSG et le véritable message que vous voulez voir. La fin %b dit à remind de terminer par « in x days time » (dans x jours) et le code entre parenthèses donne la répartition exacte du temps restant. Dans la capture ci-dessus, vous voyez qu'il restait deux jours avant la fête Minecraft organisée par mes gosses, plus précisément, la fête aurait lieu dans 1 jour 22 heures et 53 minutes.

Vous pourrez taper chaque nouveau rappel ou utiliser des bribes par-ci par-là pour rendre le processus plus rapide, mais cela faisait trop de travail pour moi. J'ai donc écrit un script très simple (ci-dessous) pour faciliter les choses.

Essentiellement, ce script pose quelques questions à l'utilisateur, puis formate les réponses dans le format de remind et ajoute le nouveau rappel au fichier des rappels.

The only problem is that this results in a list that is not sorted by due date/time, but is just a chronological list of when each reminder was written. To figure out how to sort the file, I turned to the Ubuntu forums. Advice I received from forum members Lars Noodén and ofnuts got me started and headed in the right direction. A little more time searching the web and I found a page (http://unix.stackexchange.com/questions/75366/sort-part-of-a-file) that explained how to sort part of a file. I modified their example and added it to my Reminder Maker script. (head -n 12; sort -k 2,2 -k5,5n) <~/.reminders 1<> ~/.reminders Note the (head -n 12 part of the code. This is needed because this tells sort to start sorting AFTER line 12. The reason for this is that I did not want any includes or functions to be sorted. In my reminders' file, the actual reminders begin at line 13. So I wanted everything up to and including line 12 left alone. Great, so now we have an easy way to make reminders and a way to have the reminders sorted so that they are listed based on when they are due, with the next reminder at the top of the list and the event furthest from now at the bottom of the list. How do we get it on the desktop?

Le seul problème est que cela donne une liste qui n'est pas triée par échéance jour/heure, mais n'est qu'une liste chronologique des moments où les rappels ont été écrits.

Pour essayer de comprendre comment trier le fichier, je me suis tourné vers les forums Ubuntu. Là, les conseils reçus des membres Lars Noodén et ofnuts m'ont permis de démarrer et m'ont mis sur la bonne voie. Après avoir cherché un peu plus sur le Web, j'ai trouvé une page (http://unix.stackexchange.com/questions/75366/sort-part-of-a-file) expliquant comment trier une partie d'un fichier.

J'ai modifié leur exemple et l'ai rajouté à mon script « Reminder Maker ».

(head -n 12; sort -k 2,2 -k5,5n) <~/.reminders 1<> ~/.reminders

Remarquez la partie (head -n 12 du code. Il est nécessaire, car il dit à « sort » de commencer le tri APRÈS la ligne 12, parce que je ne voulais pas que des includes ou des fonctions soit triés. Dans mon fichier des rappels, les rappels eux-mêmes commencent à la ligne 13. C'est pourquoi je voulais que tout jusqu'à, et y compris, la ligne 12, reste dans l'état.

Excellent, maintenant nous avons une méthode facile pour créer des rappels qui peuvent être triés afin qu'ils soient listés selon leur échéance, avec le prochain rappel au début de la liste et l'événement le plus éloigné à la fin. Comment la mettre sur le bureau ?

Enter conky. Configuring conky is a topic for another article. Check out the Ubuntu forums conky thread for specifics if you need to, but basically conky will read whatever is written in a conkyrc file and put that information on your desktop. Every conkyrc file has two parts. The top part, above TEXT, contains all of the Configuration Settings and the bottom part, below TEXT, contains all of the Variable Settings that you want displayed on the screen. So how do we get remind to output to conky? Below is the text part of my conkyrc file: TEXT ${execpi 60 remind -q -r /home/john/~.reminders} This tells conky to run remind every 60 seconds and display the output on my desktop. Thanks to mobildiesel for the idea of adding the -q and -r flags to the remind command. The -q option causes Remind not to queue timed reminders for later execution. The -r option disables RUN directives and the shell() function. I am not sure why, but, without these flags, my conky would crash. Adding them solved the problem. Further reading: http://conky.sourceforge.net/config_settings.html http://conky.sourceforge.net/variables.html

C'est là que conky entre en scène. Le paramétrage de conky est un sujet pour un autre article. Jetez un œil au fil conky sur les forums Ubuntu pour des détails si vous en avez besoin, mais, essentiellement, conky lira tout ce qui est écrit dans un fichier conkyrc et mettra ces informations sur le bureau. Chaque fichier conkyrc a deux parties. La partie du haut, au-dessus de TEXT contient tous les Configuration Settings (paramètres de configuration) et la partie du bas, en dessous de TEXT, contient tous les Variable Settings (paramètres des variables) que vous voulez afficher sur l'écran.

La question devient : comment faire en sorte que la sortie de remind soit envoyée à conky ? Voici la partie text de mon fichier conkyrc :

TEXT

${execpi 60 remind -q -r /home/john/~.reminders}

Ceci dit à conky d'exécuter remind toutes les 60 secondes et d'afficher la sortie sur mon bureau. Remerciements à mobildiesel pour l'idée de l'ajout des drapeaux -q et -r à la commande remind. L'option -q fait que Remind ne stocke pas les rappels pour une exécution ultérieure. L'option -r désactive les directives RUN et la fonction shell(). Je ne sais pas pourquoi, mais, sans ces drapeaux, le conky se plantait. Leur ajout a corrigé le problème.

Pour aller plus loin : http://conky.sourceforge.net/config_settings.html http://conky.sourceforge.net/variables.html

issue98/tutoriel_conky.txt · Dernière modification : 2015/07/06 07:45 de d52fr