mardi 27 octobre 2009

Makefile to convert openoffice odg files to pdf

This makefile allows converting from OpenOffice odg files to pdf files.
It requires unoconv, ps2eps and poppler-utils.

Why doing all this mess ?
Unoconv converts from odg to pdf however the resulting pdf do not fit the drawing. So this Makefile pass through a lot of format to remove all the blank around the drawing.

------------------------------------------------------------------------------

# Makefile to transform each odg file to pdf file, the size of the pdf fit with the drawing
#
# Operations :
# 1) odg -> pdft (pdf with a lot of blank around the drawing)
# 2) pdft -> ps
# 3) ps -> eps
# 4) eps -> pdf
#
# Troubleshoot : unoconv sometimes crashes when a lot of odg file are present, to avoid this
# crash call first "make pdft", then "make pdf"

ODG= $(wildcard *.odg)

PDFT= $(ODG:.odg=.pdft)
PS= $(PDFT:.pdft=.ps)
EPS= $(PS:.ps=.eps)
PDF= $(EPS:.eps=.pdf)

pdft:$(PDFT)
ps:$(PS)
eps:$(EPS)
pdf:$(PDF)

all: pdf

%.pdft: %.odg
unoconv --stdout --doctype=graphics $< > $@

%.ps: %.pdft
pdftops $< $@

%.eps: %.ps
ps2eps -f -l $<

%.pdf: %.eps
epstopdf $<

clean:
rm -f *.eps *.ps *.pdft

dist-clean:distclean

distclean: clean
rm -f *.pdf

samedi 3 octobre 2009

Script pour faire bouger la souris à intervalle régulier

J'ai un PC portable sous Debian avec des problèmes de drivers graphiques. Quand l'écran se met en veille on ne peut plus l'en faire sortir.
Même après avoir configuré mon KDE pour désactiver la mise en veille de l'écran, j'ai toujours ce problème. Sans doute l'écran se met tout seul en veille quand il voit que rien ne bouge.

J'ai donc écrit un petit script pour faire bouger la souris régulièrement afin d'éviter la mise en veille.

Il nécessite le paquet xdotool et doit fonctionner sur tous les linux.


#!/bin/bash
#===============================================================================
#
# FILE: mouseMove.sh
#
# USAGE: ./mouseMove.sh
#
# DESCRIPTION: Makes little mouse moves every 2 minutes (because I can't
# configure my laptop to avoid screen to turn off).
# It moves the cursors from coordinates X,Y to X+1,Y+1 and then
# move the cursor back to X,Y
#
# OPTIONS: --- A sleep time can be supplied (default is 2 minutes)
# REQUIREMENTS: --- xdotool package
# BUGS: ---
# NOTES: --- May be done much more elegantly
# AUTHOR: (),
# COMPANY:
# VERSION: 1.0
# CREATED: 16/08/2009 21:37:13 CEST
# REVISION: ---
#===============================================================================

if [ $# -ne 1 ]
then
SLEEP=120
else
SLEEP=$1
fi

if [ `echo $1 |grep "\\-h"` ]
then
echo "Usage : $0 "
echo "If no sleep time is supplied 2 minutes is default"
exit 1
fi

while [ 1 ]
do
X=`xdotool getmouselocation |cut -d : -f 2 |cut -d " " -f 1`
Y=`xdotool getmouselocation |cut -d : -f 3 |cut -d " " -f 1`
XPP=$((X+1))
YPP=$((Y+1))

xdotool mousemove ${XPP} ${YPP}
xdotool mousemove ${X} ${Y}
sleep ${SLEEP}

done