Site perso : Emmanuel Branlard
#!/usr/bin/python
import os, string
h = open( 'playlists.xml', 'w' )
h.write('<?xml version="1.0"?>\n')
h.write('<rhythmdb-playlists>\n')
h.write(' <playlist name="Play Queue" type="queue"/>\n')
h.write(' <playlist name="My Top Rated" type="automatic" sort-key="Rating" sort-direction="1">\n')
h.write(' <conjunction>\n')
h.write(' <equals prop="type">song</equals>\n')
h.write(' <subquery>\n')
h.write(' <conjunction>\n')
h.write(' <greater prop="rating">4.000000</greater>\n')
h.write(' </conjunction>\n')
h.write(' </subquery>\n')
h.write(' </conjunction>\n')
h.write(' </playlist>\n')
h.write(' <playlist name="Recently Added" type="automatic" sort-key="Artist" sort-direction="0">\n')
h.write(' <conjunction>\n')
h.write(' <equals prop="type">song</equals>\n')
h.write(' <subquery>\n')
h.write(' <conjunction>\n')
h.write(' <current-time-within prop="first-seen">604800</current-time-within>\n')
h.write(' </conjunction>\n')
h.write(' </subquery>\n')
h.write(' </conjunction>\n')
h.write(' </playlist>\n')
h.write(' <playlist name="Recently Played" type="automatic" sort-key="Artist" sort-direction="1">\n')
h.write(' <conjunction>\n')
h.write(' <equals prop="type">song</equals>\n')
h.write(' <subquery>\n')
h.write(' <conjunction>\n')
h.write(' <current-time-within prop="last-played">604800</current-time-within>\n')
h.write(' </conjunction>\n')
h.write(' </subquery>\n')
h.write(' </conjunction>\n')
h.write(' </playlist>\n')
if not os.path.exists('playlists'):
os.makedirs('playlists')
os.chdir('playlists')
a = open( 'order_file', 'r' )
for b in a.xreadlines():
if b[-1:] == '\n':
b = b[:-1]
if b[-1:] == '\r':
b = b[:-1]
if b == 'EOF':
break
c = open( b+'.playlist', 'r' )
b = string.replace( b, '&', '&' )
h.write(' <playlist name="'+b+'" type="static">\n')
for line in c.xreadlines():
if line[-1:] == '\n':
line = line[:-1]
if line[-1:] == '\r':
line = line[:-1]
if line != 'EOF':
if line.find('\t') != -1:
line = line[:line.find('\t')]
line = string.replace( line, '&', '&' )
h.write(' <location>'+line+'</location>\n')
else:
break
c.close()
h.write(' </playlist>\n')
a.close()
h.write('</rhythmdb-playlists>\n')
h.close()
#! /usr/bin/expect -f set force_conservative 1; set timeout 2 spawn ssh -T -l LOGIN HOST expect "password: $" send "MOTDEPASSE\n" interact
#!/bin/sh #initialization HOME=/home/manu folder=backup_data/ mydate=$(date +%Y-%m-%d-%H%M) folder=$HOME"/Config/"$folder$mydate mkdir -p $folder cd $folder echo $folder #creating arborescence mkdir -p home/config mkdir -p home/local/share/rhythmbox mkdir -p home/mozilla/firefox/ mkdir -p etc/network mkdir -p log mkdir etc/event.d mkdir etc/grub.d/ mkdir etc/cron.daily/ mkdir etc/cron.weekly/ mkdir etc/X11 mkdir etc/apt mkdir etc/texmf mkdir etc/samba mkdir etc/default mkdir etc/ssh mkdir etc/apache2 mkdir etc/logrotate.d mkdir -p lib/lsb/ mkdir etc/proftpd mkdir etc/fail2ban #mkdir -p etc/gdm/Init/ # liste des paquets dpkg --get-selections > liste-paquets.dpkg #home folder cp $HOME/Config/profiles/bash* home/ cp $HOME/.vimrc home/vimrc cp -r $HOME/.vim/ home/vim cp $HOME/.xinitrc home/xinitrc cp $HOME/.Xdefaults home/Xdefaults cp $HOME/.conkyrc home/conkyrc cp $HOME/.asoundrc home/asoundrc cp -r $HOME/.config/* home/config/ cp $HOME/.local/share/rhythmbox/*.xml home/local/share/rhythmbox/ #cp -r $HOME/.mozilla/firefox home/mozilla/firefox #system cp /etc/fstab etc/fstab cp /etc/modules etc/modules #cp /etc/event.d/tty1 etc/event.d/tty1 cp /etc/issue etc/issue cp /etc/inittab etc/ cp /etc/sudoers etc cp /etc/group etc/ cp /etc/passwd etc/passwd cp /etc/cron.daily/* etc/cron.daily/ cp /etc/cron.weekly/* etc/cron.weekly/ cp /etc/logrotate.conf etc/logrotate.conf cp /etc/logrotate.d/rsyslog etc/logrotate.d/rsyslog cp /etc/network/interfaces etc/network/interfaces cp /etc/X11/xorg.conf etc/X11/xorg.conf cp /etc/apt/sources.list etc/apt/sources.list cp /etc/apt/preferences etc/apt/preferences #cp /boot/grub/menu.lst menu.lst cp /boot/grub/grub.cfg grub.cfg cp /etc/grub.d/* etc/grub.d/ cp /etc/sysctl.conf etc/ cp /etc/default/rcS etc/default/rcS cp /lib/lsb/init-functions lib/lsb/ #programs cp /etc/latex2html.conf etc/ cp /etc/texmf/texmf.cnf etc/texmf/texmf.cnf cp /etc/samba/smb.conf etc/samba/ cp -R /etc/apache2/* etc/apache2/ cp /etc/ssh/sshd_config etc/ssh/ #cp /etc/gdm/Init/Default etc/gdm/Init/Default cp /etc/proftpd/proftpd.conf etc/proftpd/ cp /etc/proftpd/msg/* etc/proftpd cp /etc/fail2ban/jail.local etc/fail2ban #processus init cp -R /etc/init.d etc/init.d cp -R /etc/rc0.d etc/rc0.d cp -R /etc/rc1.d etc/rc1.d cp -R /etc/rc2.d etc/rc2.d cp -R /etc/rc3.d etc/rc3.d cp -R /etc/rc4.d etc/rc4.d cp -R /etc/rc5.d etc/rc5.d cp -R /etc/rc6.d etc/rc6.d cp -R /etc/rcS.d etc/rcS.d #logs cp /var/log/dmesg log/dmesg cp /var/log/daemon.log log/daemon.log cp /var/log/messages log/messages cp /var/log/syslog log/syslog cp /var/log/kern.log log/kern.log cp /var/log/aptitude log/ #Giving rights to all files cd ../../ chown -R manu:manu $folder
#!/bin/bash ############################################################# # Default script: ############################################################# umount /mnt/R-home/ umount /mnt/S-group/ umount /mnt/T-apps/ umount /mnt/U-garb/
#!/usr/bin/python
#############################################################
# Show Tag
#############################################################
# Description: notify audio tags
# Written by : Emmanuel Branlard
# Date : March 2011
# Dependencies :
# License : Feel free to modify and adapt it
# Note :
#############################################################
import mutagen
import optparse
import subprocess
parser = optparse.OptionParser()
(options, args) = parser.parse_args()
def getKey(audio,key):
try:
f=audio[key].pop().encode('utf-8')
except KeyError:
print "caught"
f=""
return(f)
audio=mutagen.File(args[0], easy=True)
artist=getKey(audio,'artist')
album=getKey(audio,'album')
songtitle=getKey(audio,'title')
genre=getKey(audio,'genre')
year=getKey(audio,'date')
print artist
print songtitle
print album
print genre
print year
subprocess.call(["notify-send",artist+"\n"+songtitle+"\n"+album+"\n"+genre+"\n"+year])
#!/bin/sh # Sould be run as user #variables OPTS="-av" DEST=/media/Storage ############## # DATAWIN ############## SRC=/media/DataWin #without deletion rsync $OPTS $SRC/Etudes/ $DEST/Etudes/ rsync $OPTS $SRC/Images/ $DEST/Images/ #with delete propagation rsync $OPTS --delete $SRC/Config/ $DEST/Config/ rsync $OPTS --delete $SRC/Data/ $DEST/Data/ rsync $OPTS --delete $SRC/Informatique/ $DEST/Informatique/ rsync $OPTS --delete $SRC/Musique/ $DEST/Musique/ rsync $OPTS --delete "$SRC/Musique - Data/" "$DEST/Musique - Data/" rsync $OPTS --delete "$SRC/Musique Classique/" "$DEST/Musique Classique/" rsync $OPTS --delete $SRC/Projets/ $DEST/Projets/ rsync $OPTS --delete $SRC/Work/ $DEST/Work/ ############## # Linux ############## SRC=/home/manu #without deletion rsync $OPTS $SRC/Sites/ $DEST/Sites/ #with delete propagation rsync $OPTS --delete $SRC/Config/ "$DEST/Config - Linux/"
#!/bin/bash
#############################################################
# audioInfo: prints audio info, metadata, bit rate
#############################################################
# Description :
# Written by : Emmanuel Branlard
# Date : March 2011
# Dependencies :
# License : Feel free to modify and adapt it
# Note :
#############################################################
Duration=`ffmpeg -i "$@" 2>&1 |grep Duration | awk -F":|," '{print $3":"int($4)}'`
MetaData=`ffmpeg -i "$@" 2>&1 |grep -E " artist |title |album |genre|TYER"|awk -F: '{print " "$2}'`
Stream=`ffmpeg -i "$@" 2>&1 |grep Stream | awk -F, '{print $1"\n "$2 $3 $4"\n "$5}'`
Bitrate=`ffmpeg -i "$@" 2>&1|awk '/bitrate:/ {print $6" "$7}'`
#xargs -0
echo $Duration
echo $Stream
echo $MetaData
Out="MetaData:
$MetaData
-----------------------------------------
Length: $Duration
Bitrate: $Bitrate
-----------------------------------------
Audio:
$Stream"
notify-send -t 3000 -i gnome-volume-control "$Out"
#!/bin/sh
#############################################################
# Shrink Fig
#############################################################
# Description : Shrink Figure to 60%
# Written by : Emmanuel Branlard
# Date : March 2011
# Dependencies : image magick
# License : Feel free to modify and adapt it
#############################################################
for i
do
mogrify -resize 60% $i
done
#!/bin/bash source /opt/intel/Compiler/11.1/069/bin/ifortvars.sh ia32
#! /bin/bash rm *.aux rm *.toc rm *.log rm *.bbl rm *.out rm *.cb rm *.blg rm *.lot rm *.lof rm *.tps rm *.maf rm *.ilg rm *.glo rm *.mtc* rm *.ptc* rm *.bmt rm *.idx rm *.ind rm *.snm rm *.nav rm *.cb2
#!/bin/sh ############################################################# # Send It ############################################################# # Description : Send file by email # Written by : Emmanuel Branlard # Date : October 2011 # Dependencies : mutt # License : Feel free to modify and adapt it ############################################################# #notify-send "Email to:$a $1" export mydate=$(date +%Y-%m-%d-%H%M-%S); xterm -geometry 30x2+550+400 +sb -e 'echo "email address";read a;echo $a>/tmp/sendit$mydate.tmp'; #xterm -geometry 30x2+550+400 +sb -e 'a=EMAIL@gmail.com;mydate=$(date +%Y-%m-%d-%H%M-%S); echo $a>/tmp/sendit$mydate.tmp;a'; to=`cat /tmp/sendit$mydate.tmp`; notify-send "$to $@" -i mail-attachment -t 3000; echo "Hi I attached $# File(s) to this email. Best, Emmanuel Sent with my geeky shell script " | mutt -a "$@" -s "Sent file(s) ($1)" -- $to ; rm /tmp/sendit$mydate.tmp notify-send "File sent! $@" -t 3000 -i mail-forward
#! /bin/bash
if [ $# -eq 0 ]
then
Files=*.png
Files="$Files"
else
l=$@
Buff=""
First=''
for i in $l
do
if [ ! `echo $i |grep -E "[.][a-zA-Z]{3,4}$"` = "" ]
then
File="$Buff $i"
Buff=""
First=""
File2=`echo $File|tr ' ' '_'`
#
if [ $File != $File2 ]
then
mv "$File" $File2
fi
#
Files="$Files $File2"
else
if [ -z ${First} ]
then
Buff="$i"
First="no"
else
Buff="$Buff $i"
fi
fi
done
# echo $Files
fi
FileOut=`echo $Files|grep -Eo "^[a-Z0-9\_ -]*[.]"|tr '_' ' '`"pdf"
echo $FileOut
#convert $Files "$FileOut"
convert -page A4 -units PixelsPerInch -normalize -density 100 $Files "$FileOut"
#! /bin/bash echo "Looking for "$1 SAVEIFS=$IFS IFS=$(echo -en "\n\b") for i in `find -name "*.pdf" -printf '%h/%f\n' 2> /dev/null` do echo "----------------------------" echo "$i"; echo "----------------------------" pdftotext $i - |grep --color=always $1 # strings "$i" |grep $1 done; IFS=$SAVEIFS
#!/bin/sh # @(#) TITLE MESSAGE: Recuperation des cles GPG et exportation vers apt # @(#) Feilong version 05/01/2009 # @(#) Syntaxe: GETKEY KEY # @(#) MACHINE VM DEBIAN lenny if [ $(id -u) != "0" ]; then echo “Seul root peut executer ce shell” >&2 exit 1 fi if [ $# -ne 1 ]; then echo “syntaxe : GETKEY <votre cle>” exit 1 fi gpg –keyserver hkp://wwwkeys.eu.pgp.net –recv-keys $1 if [ $? -ne 0 ]; then echo ” Une erreur est survenu pendant le téléchargement de la clé” exit 1 fi gpg –armor –export $1 | apt-key add - if [ $? -ne 0 ]; then echo ” Une erreur est survenu pendant l’export de la clé vers apt” exit 1 fi apt-get update
#!/bin/sh
#############################################################
# Shrink Fig
#############################################################
# Description : Shrink Figure to 40%
# Written by : Emmanuel Branlard
# Date : March 2011
# Dependencies : image magick
# License : Feel free to modify and adapt it
#############################################################
for i
do
mogrify -resize 40% $i
done
#!/usr/bin/python
'''
Copyright (C) 2008,2009,2010 Richard Henwood, rjhenwood@yahoo.co.uk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
------------------------------------------
'''
# We will use inex module with predefined effect base class.
import string
from optparse import OptionParser
from xml.dom.minidom import parse, parseString, Node
from string import Template
import pprint
import re
import sys
import os.path
import math
import subprocess
import tempfile
import shutil
import platform
class svg2latex():
""" Constructor.
Defines "--what" option of a script."""
myHorizontalFudgePX = -8 # we have to knudge text over a bit to get it to align horizontally.
#flow_x_offset = -3.47433
#flow_y_offset = 9.4698369
flow_x_offset = 0.0
flow_y_offset = 0.0
#####################################################################
def svgfile_handler(option, opt, value, parser):
print ("option = %s" % option)
print ("opt = %s" % opt)
print ("value = %s" % value)
print ("parser = %s" % parser)
def __init__(self):
# Call base class construtor.
usage = """Convert svg to latex picture format and use
Inkscape to generate a pdf for all the bits
which are not text.
-f [--svgfile] <filename> svgfilename.
-l [--latexoutfile] <filename> name for latex output file.
-o overwrite the output files automatically.
-e create an eps file instead of pdf.
A pdf file is also created. This is given the same name as the
latex outfile with the extension 'pdf'. This file is generated by
Inkscape, which must be on the path for this script to work.
"""
parser = OptionParser(usage)
parser.add_option("-f", "--svgfile", dest="svgfilename",
help="svg input file")
parser.add_option("-l", "--latexoutfile", dest="latexfilename",
help="latex file to output to")
parser.add_option("-o", "--overwrite", dest="overwrite",
action="store_true",
help="automatically overwrite output")
parser.add_option("-e", "--epsoutput", dest="epsoutput",
action="store_true",
help="make eps instead of pdf")
(options, args) = parser.parse_args()
if options.latexfilename is None:
print ("--latexoutfile not specified")
sys.exit(usage)
self.latexfilename = options.latexfilename
latexhead, latextail = os.path.split(self.latexfilename)
if (latexhead is not None and latexhead is not ""):
latexhead += os.sep
latexroot, latexext = os.path.splitext(latextail)
self.epsfileoutput = None
if options.epsoutput is None:
self.lateximagefile = latexhead + latexroot + '.pdf'
else:
self.lateximagefile = latexhead + latexroot + '.eps'
self.epsfileoutput = 1
self.latexsvgtmp = tempfile.NamedTemporaryFile(delete=False)
if options.svgfilename is None:
print ("--svgfile not specified")
sys.exit(usage)
if options.overwrite is None:
self.autooverwrite = 0
else:
self.autooverwrite = options.overwrite
self.svgfilename = options.svgfilename
print (" svg filename = %s" % self.svgfilename)
print (" latex image file = " + self.lateximagefile)
print (" latex input file = " + self.latexfilename)
self.origsvg = parse(self.svgfilename)
self.notextsvg = parse(self.svgfilename)
# these namespaces are useful.
# xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
# xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
# xmlns="http://www.w3.org/2000/svg"
#####################################################################
def tidyup(self):
os.unlink(self.latexsvgtmp.name)
#####################################################################
def makePDF(self):
# first, make a copy of the svg with all the text removed.
for element in self.notextsvg.getElementsByTagName("flowRoot"):
element.parentNode.removeChild(element)
for element in self.notextsvg.getElementsByTagName("text"):
element.parentNode.removeChild(element)
# and save it in a temp file
self.notextsvg.writexml(self.latexsvgtmp)
self.latexsvgtmp.close()
# now call inkscape with this file to produce a
# pdf version.
# TODO: this is a hard dependency on inkscape which might
# be nice to replace with cairo at some later
# date...
temppdffile = tempfile.NamedTemporaryFile(delete=False)
temppdffile.close()
exportcmd = "--export-eps"
if self.epsfileoutput is None:
exportcmd = " --export-pdf "
inkscapecmd = "inkscape"
if platform.system() == 'Windows':
inkscapecmd = "C:\\Program Files\\Inkscape\\inkscape.exe"
sys.stderr.write(inkscapecmd+exportcmd+temppdffile.name+"--file"+self.latexsvgtmp.name+"\n")
subprocess.call([inkscapecmd,exportcmd, temppdffile.name, " --file ", self.latexsvgtmp.name])
#print "copying file to: " + self.lateximagefile
shutil.copy(temppdffile.name, self.lateximagefile)
os.unlink(temppdffile.name)
#####################################################################
def toLatex(self):
filename = self.latexfilename
if os.path.isfile(filename) and not self.autooverwrite:
sys.stderr.write("File '" + filename + "' already exists. Quitting.\n")
sys.exit()
FILE = open(filename,"w")
# we need to extract the global translation of the whole
# page.
dom1 = parse(self.svgfilename)
#pprint.pprint(dom1)
ele_g = dom1.getElementsByTagName("g")[0]
ele_svg = dom1.getElementsByTagName("svg")[0]
pgheight = ele_svg.attributes["height"].value
if pgheight.endswith("mm"):
pgheight = pgheight.rstrip("mm")
pgheight = float(pgheight) * 3.5433
pgwidth = ele_svg.attributes["width"].value
if pgwidth.endswith("mm"):
pgwidth = pgwidth.rstrip("mm")
pgwidth = float(pgwidth) * 3.5433
latexstr = self.page_info(pgwidth, pgheight)
# TODO, remove the g_trans var from global scope.
for node in dom1.getElementsByTagName("flowRoot"):
g_trans_x, g_trans_y = self.get_g_trans(node)
latexstr += "\n"
latexstr += self.process_flow(node, pgwidth, pgheight, g_trans_x, g_trans_y)
latexstr += "\n"
for node in dom1.getElementsByTagName("text"):
g_trans_x, g_trans_y = self.get_g_trans(node)
latexstr += "\n"
latexstr += self.process_text(node, pgwidth, pgheight, g_trans_x, g_trans_y)
latexstr += "\n"
latexstr += " \\end{picture}\n"
latexstr += "\\endgroup\n"
FILE.writelines(str(latexstr.encode("utf-8")))
FILE.close()
#####################################################################
def get_g_trans(self, node):
#pprint.pprint(node.toxml())
x_trans, y_trans = (0, 0)
while not node.nodeType == Node.DOCUMENT_NODE:
if node.hasAttribute("transform") == True:
#print "found transform..."
trans_str = node.attributes["transform"].value;
tmp_x, tmp_y = self.get_trans(trans_str)
x_trans += tmp_x
y_trans += tmp_y
node = node.parentNode
return x_trans, y_trans
def get_trans(self, trans_str):
trans_str = trans_str.rstrip(")")
x_trans = 1.0
y_trans = 1.0
if "translate" in trans_str:
#print "translate! str = ", trans_str
trans_str = trans_str.lstrip("translate(")
values = trans_str.split(",")
else:
#print "not translate! str = ", trans_str
trans_str = trans_str.lstrip("matrix(")
values = trans_str.split(",")
# fix the x,y if there is a scale value included in the matrix
#print "values = ", values[0], values[3]
#values[-2] = float(values[0]) * float(values[-2])
#values[-1] = float(values[3]) * float(values[-1])
return float(values[-2]), float(values[-1])
def get_global_trans(self, trans_str):
tmp_str = trans_str.lstrip("translate(")
tmp_str = tmp_str.rstrip(")")
return map(lambda x: float(x), tmp_str.split(","))
#####################################################################
def page_info(self, pgwidth, pgheight):
pagestr = ''
pagestr += "\\begingroup\n"
pagestr += " \setlength{\unitlength}{0.8pt}\n" # this is standard SVG units, as PT.
pagestr += " \\begin{picture}("
pagestr += str(pgwidth)
pagestr += ","
pagestr += str(pgheight)
pagestr += ")\n"
pagestr += " \put(0,0){\includegraphics"
pagestr += "{"
pagestr += re.sub(r'\\', r'/', self.lateximagefile)
pagestr += "}}\n"
return pagestr
#####################################################################
def process_style(self, stylenode):
color = "{black}"
fontSize = ""
customColors = ""
colorNum = 1
mboxcode = ''
fontSizeInt = 1;
fontSizeFloat = 10;
if stylenode is not None:
for styleElement in string.split(stylenode, ';'):
directive, value = string.split(styleElement, ':')
if directive == "text-align":
#print "directive found:", directive, value
if value == 'center':
mboxcode = 'c'
elif value == 'end':
mboxcode = 'r'
else:
mboxcode = 'l'
if directive == "fill":
if re.match(r'^#', value) is not None:
color = "{inkcol" + `colorNum` + "}"
red = '0x' + value[1:3]
green = '0x' + value[3:5]
blue = '0x' + value[5:7]
customColors += "\\definecolor{inkcol" + `colorNum` + "}{rgb}{"
customColors += `eval(red)/255.0` + ','
customColors += `eval(green)/255.0` + ','
customColors += `eval(blue)/255.0` + '}\n'
colorNum += 1
else:
color = "{" + value + "}"
if directive == "font-size":
fontSize,fontSizeFloat = self.fontSizeLookup(value)
#print "fontsize: " + fontSize
#print "fontsizefloat: " + fontSizeFloat
return color, fontSize, customColors, colorNum, mboxcode, fontSizeFloat
#####################################################################
def process_tspan_transform(self, transform, tmpx, tmpy):
rotate = 0
transX = 0
transY = 0
if transform is not None:
transArrTmp = re.split(r"[,\(\)]", transform)
transArr = []
for element in transArrTmp:
if re.search('^[-+]?\d+\.?\d*', element):
transArr.append(element)
transX = tmpx #float(transArr[-2])
transY = tmpy #float(transArr[-1])
if re.match(r'^matrix', transform) is not None:
rotate = self.get_angle(transArr[0], transArr[1], transArr[2], transArr[3])
# print "determinant= ", self.get_determinant(transArr[0], transArr[1], transArr[2], transArr[3])
transX, transY = self.do_transform(transArr[0], transArr[2], transArr[1], transArr[3], tmpx, tmpy)
return rotate, transX, transY
#####################################################################
# this processes <text> dom elements.
# it is as ugly as it looks.
# TODO: add code to deal with 'align-centre' style.
def process_text(self, flowNode, imgWidth, imgHeight, g_x_trans, g_y_trans):
#tmpstr = ''
style = flowNode.attributes["style"]
color, fontSize, customColors, colorNum, mboxcode, fontSizeInt = self.process_style(style.value)
put = Template(' \put($x,$y)')
rotate, transX, transY = (0.0, 0.0, 0.0)
tmpx = float(flowNode.attributes["x"].value)
tmpy = float(flowNode.attributes["y"].value)
if flowNode.hasAttribute("transform"):
transform = flowNode.attributes["transform"].value
# this is a hack for the cases where inkscape optimises
# a 180o rotation into a scale(-1,-1)
if transform.startswith("scale("):
transform = "matrix(-1,0,0,-1)"
rotate, transX, transY = self.process_tspan_transform(transform, 0.0, 0.0)
alltext = ''
(x2, y2) = (None, None)
for element in flowNode.getElementsByTagName("tspan"):
#x1 = (float(element.attributes["x"].value))
#y1 = (float(element.attributes["y"].value))
x1 = tmpx
y1 = tmpy
x2 = transX + x1*math.cos(rotate) - y1*math.sin(rotate)
y2 = transY + x1*math.sin(rotate) + y1*math.cos(rotate)
x2 += g_x_trans
y2 += g_y_trans
y2 = float(imgHeight) - y2
myWidth = float(imgWidth)
if mboxcode == 'c':
# this block adjusts x coord for
# cases where we wish to centre the text.
x2 -= myWidth/2.0
if element.hasAttribute("style"):
fontSize = self.get_fontsize(element.attributes["style"].value, fontSize)
if element.firstChild is not None:
alltext += "\\textcolor" + color + "{" + fontSize + "{" + element.firstChild.data + "}}\\\\\n"
# vskip -1cm
#print "text: " + alltext + " g_pos ", g_x_trans, g_y_trans
#print "\n"
txt = Template('{\\rotatebox{' + `self.toDEG(rotate)` + '}{\makebox(0,0)[tl]{\strut{}{$text}}}}%\n')
miniPg = '\n \\begin{minipage}[h]{' + str(myWidth * 0.8) + 'pt}\\vspace{-2ex}\n'
if mboxcode == 'c':
miniPg += '\\begin{center}\n'
miniPg += alltext
miniPg += '\\end{center}\n'
elif mboxcode == 'r':
miniPg += '\\begin{flushright}\n'
miniPg += alltext
miniPg += '\\end{flushright}\n'
else:
miniPg += alltext
miniPg += '\end{minipage}'
return customColors + put.substitute(x=x2, y=y2) + txt.substitute(text=miniPg)
#####################################################################
def process_flow(self, flowNode, imgWidth, imgHeight, g_x_trans, g_y_trans):
tmpstr = ''
style = flowNode.attributes["style"]
color, fontSize, customColors, colorNum, mboxcode, fontSizeInt = self.process_style(style.value)
put = Template(' \put($x,$y)')
#print "flow processing"
rotate, transX, transY = (0.0, 0.0, 0.0)
if flowNode.hasAttribute("transform"):
transform = flowNode.attributes["transform"]
rotate, transX, transY = self.process_tspan_transform(transform.value, 0.0, 0.0)
for element in flowNode.getElementsByTagName("rect"):
x1 = (float(element.attributes["x"].value))# + g_x_trans + self.flow_x_offset
y1 = (float(element.attributes["y"].value))# + g_y_trans + self.flow_y_offset
x2 = transX + x1*math.cos(rotate) - y1*math.sin(rotate)
y2 = transY + x1*math.sin(rotate) + y1*math.cos(rotate)
x2 = x2 + g_x_trans
y2 = y2 + g_y_trans
#print "x2: ", (float(element.attributes["x"].value)), g_x_trans, transX, x1, x2
#print "y2: ", (float(element.attributes["y"].value)), g_y_trans, transY, y1, y2
y2 = float(imgHeight) - y2
tmpstr += put.substitute(x=x2, y=y2)
myWidth = float(element.attributes["width"].value)
alltext = ''
for element in flowNode.getElementsByTagName("flowPara"):
if element.hasAttribute("style"):
fontSize = self.get_fontsize(element.attributes["style"].value, fontSize)
if element.firstChild is not None:
alltext += "\\textcolor" + color + "{" + fontSize + "{" + element.firstChild.data + "}}\\\\\n"
#print alltext
txt = Template('{\\rotatebox{' + `self.toDEG(rotate)` + '}{\makebox(0,0)[tl]{\strut{}{$text}}}}%\n')
miniPg = '\n \\begin{minipage}[h]{' + str(myWidth * 0.8) + 'pt}\n'
if mboxcode == 'c':
miniPg += '\\begin{center}\n'
miniPg += alltext
miniPg += '\\end{center}\n'
elif mboxcode == 'r':
miniPg += '\\begin{flushright}\n'
miniPg += alltext
miniPg += '\\end{flushright}\n'
else:
miniPg += alltext
miniPg += '\end{minipage}'
tmpstr += txt.substitute(text=miniPg)
return customColors + tmpstr
#####################################################################
def get_fontsize (self, att, fontSize):
size = att.partition("font-size:")[2]
size = size.partition(";")[0]
if size is None:
return fontSize
return self.fontSizeLookup(size)[0]
def do_transform(self, a,b,c,d,x,y):
x2 = float(a)*float(x) + float(b)*float(y)
y2 = float(c)*float(x) - float(d)*float(y)
return (x2, y2)
def undo_transform(self, a,b,c,d,x,y):
x2 = float(a)*float(x) + float(b)*float(y)
y2 = -float(c)*float(x) + float(d)*float(y)
return (x2, y2)
def get_determinant(self, a,b,c,d):
return float(a)*float(d) - float(b)*float(c)
def get_angle(self, x1, x2, y1, y2):
#sys.stderr.write("angle '" + x1 + "'." + x2 + "'." + y1 + "'." + y2 + "'.")
acosA = math.acos(float(x1))
if (math.asin(float(x2)) >= 0):
return float(acosA)
else:
return 2*math.pi - float(acosA)
def toDEG(self, rad):
return 360-180.0*rad/math.pi
def fontSizeLookup (self, pxSize):
sizeStr = "\\normalsize"
if not re.search('px$', pxSize):
try:
float(pxSize)
except ValueError:
sys.stderr.write("found unusual font size: " + pxSize + " assuming '\\normalsize' missing.\n")
return "\\normalsize", 10
sys.stderr.write("found unusual font size: " + pxSize + " assuming 'px' missing.\n")
pxSize += "px"
#print "Pxsize = " + pxSize
size = re.split(r"px$", pxSize)
#print "size = " + size
size[0] = float(size[0])
if size[0] < 7:
return "\\tiny", size[0]
if size[0] < 8:
return "\\scriptsize", size[0]
if size[0] < 9:
return "\\footnotesize", size[0]
if size[0] < 10:
return "\\small", size[0]
if size[0] < 12:
return "\\normalsize", size[0]
if size[0] < 14:
return "\\large", size[0]
if size[0] < 18:
return "\\Large", size[0]
if size[0] < 20:
return "\\LARGE", size[0]
if size[0] < 24:
return "\\huge", size[0]
if size[0] >= 24:
return "\\Huge", size[0]
sys.stderr.write("found unusual font size: " + pxSize + " assuming normalsize.")
return "\\normalsize", 10
#\tiny 5 5
#\scriptsize 7 7
#\footnotesize 8 8
#\small 9 9
#\normalsize 10 10
#\large 12 12
#\Large 14 14.40
#\LARGE 18 17.28
#\huge 20 20.74
#\Huge 24 24.88
#else:
# sys.stderr.write("found unusual font size: " + pxSize + " assuming normalsize.")
# return "\\normalsize", 10
svgfile = svg2latex()
svgfile.toLatex()
svgfile.makePDF()
svgfile.tidyup()
print ("completed")
#!/bin/bash ############################################################# # Default script: ############################################################# mount /mnt/R-home/ mount /mnt/S-group/ mount /mnt/T-apps/ mount /mnt/U-garb/
#!/bin/sh if xprop -root _NET_SHOWING_DESKTOP|egrep '= 1' ; then wmctrl -k off ; else wmctrl -k on ; fi
#!/bin/bash
echo "Usage: pdf2ocr.sh FILE.pdf lang"
if [ -e tmp ] ;
then
echo "Folder tmp/ exists - Continue anyway ?" ;
echo " YES : Press Enter ";
echo " NO : Press Ctrl+C ";
read reply
else
mkdir tmp
fi
echo " "
echo "- Entering folder tmp"
cd tmp
ERRORS=0
echo " "
echo "- Bursting with pdftk..."
pdftk "../$1" burst dont_ask
echo " "
for f in pg_*.pdf
do
echo "- Pre-processing $f ...";
convert -quiet -monochrome -normalize -density 300 "$f" "$f.png";
done
echo " "
for f in pg_*.png
do
echo "- Processing $f ..."
convert "$f" "$f.bmp"
echo "Merging BMP and hOCR into PDF file..."
cuneiform -l $2 -f hocr -o "$f.php" "$f.bmp"
convert -blur 0.4 "$f" "$f.bmp"
OUT=$?
hocr2pdf -i "$f" -s -o "$f.pdf" < "$f.php"
OUT=`expr $? + $OUT`
if [ $OUT -gt 127 ] ;
then
echo "$f" >> ../errors.log ;
ERRORS=`expr $ERRORS + 1` ;
cp "${f%%.png}" "$f.pdf"
fi
rm -f "$f.bmp"
done
echo " "
echo "- Binding with pdftk..."
pdftk pg_*.png.pdf output "../$1-OCR.pdf"
echo " "
if [ $ERRORS -gt 0 ] ;
then
echo "- Number of errors $ERRORS"
cat ../errors.log
fi
echo "Done, should I delete all the temporary files?"
echo " YES : Press Enter ";
echo " NO : Press Ctrl+C ";
read reply
rm -r pg_*
#!/bin/bash
echo "usage: pdfocr.sh document.pdf \"author\" \"title\""
# Adapted from http://blog.konradvoelkel.de/2010/01/linux-ocr-and-pdf-problem-solved/
# NOTE: This script has been substantially modified/simplified from the original.
# This version does not allow rotation, language selection or cropping.
# Those parameters were all required in the original, but I don't really need them.
# If you can think of a way to make them optional, please share.
# This version also uses Tesseract, which I find to be substantially more
# accurate than Cuneiform for English text.
# usage examples:
#echo "InfoKey: Author" > in.info
#echo "InfoValue: $2" >> in.info
#echo "InfoKey: Title" >> in.info
#echo "InfoValue: $3" >> in.info
#echo "InfoKey: Creator" >> in.info
#echo "InfoValue: PDF OCR scan script" >> in.info
#pdfjoin --fitpaper --tidy --outfile "$1.ocr1.pdf" "pg_*-ocr.pdf"
#rm -f pg_*
#pdftk "$1.ocr1.pdf" update_info doc_data.txt output "$1.ocr2.pdf"
#pdftk "$1.ocr2.pdf" update_info in.info output "$1-ocr.pdf"
#rm -f "$1.ocr1.pdf" "$1.ocr2.pdf" doc_datax.txt in.info
#!/bin/bash
echo "Usage: pdf2ocr.sh FILE.pdf lang"
if [ -e tmp ] ;
then
echo "Folder tmp/ exists - Continue anyway ?" ;
echo " YES : Press Enter ";
echo " NO : Press Ctrl+C ";
read reply
else
mkdir tmp
fi
echo " "
echo "- Entering folder tmp"
cd tmp
ERRORS=0
echo " "
echo "- Bursting with pdftk..."
pdftk "../$1" burst dont_ask
echo " "
for f in pg_*.pdf
do
echo "- Pre-processing $f ...";
# convert -quiet -monochrome -normalize -density 300 "$f" "$f.png";
convert -quiet -density 300 -depth 8 "$f" "$f.tif"
done
echo " "
for f in pg_*.tif
do
echo "- Processing $f ..."
tesseract "$f" "$f" hocr
echo "Merging BMP and hOCR into PDF file..."
hocr2pdf -i "$f" -o "$f-ocr.pdf" <"$f.php"
OUT=$?
if [ $OUT -gt 127 ] ;
then
echo "$f" >> ../errors.log ;
ERRORS=`expr $ERRORS + 1` ;
cp "${f%%.png}" "$f.pdf"
fi
done
echo " "
echo "- Binding with pdftk..."
pdftk pg_*.png.pdf output "../$1-OCR.pdf"
echo " "
if [ $ERRORS -gt 0 ] ;
then
echo "- Number of errors $ERRORS"
cat ../errors.log
fi
echo "Done, should I delete all the temporary files?"
echo " YES : Press Enter ";
echo " NO : Press Ctrl+C ";
read reply
rm -r pg_*
#!/bin/bash
#### Create ~/.pulse/mute if not exists
ls ~/.pulse/mute &> /dev/null
if [[ $? != 0 ]]
then
echo "false" > ~/.pulse/mute
fi
####Create ~/.pulse/volume if not exists
ls ~/.pulse/volume &> /dev/null
if [[ $? != 0 ]]
then
echo "65536" > ~/.pulse/volume
fi
CURVOL=`cat ~/.pulse/volume` #Reads in the current volume
MUTE=`cat ~/.pulse/mute` #Reads mute state
if [[ $1 == "increase" ]]
then
CURVOL=$(($CURVOL + 1311)) #3277 is 5% of the total volume, you can change this to suit your needs.
if [[ $CURVOL -ge 95536 ]]
then
CURVOL=95536
fi
elif [[ $1 == "decrease" ]]
then
CURVOL=$(($CURVOL - 1311))
if [[ $CURVOL -le 0 ]]
then
CURVOL=0
fi
elif [[ $1 == "mute" ]]
then
if [[ $MUTE == "false" ]]
then
pactl set-sink-mute 1 1
echo "true" > ~/.pulse/mute
icon="audio-volume-muted"
notify-send -t 500 -i $icon "Mute: on"
exit
else
pactl set-sink-mute 1 0
echo "false" > ~/.pulse/mute
# icon="audio-volume-low"
# if [[ $CURVOL -ge 50000 ]]
# then
# icon="audio-volume-high"
# elif [[ $CURVOL -ge 30000 ]]
# then
# icon="audio-volume-medium"
# fi
# a=00
# p=`expr $CURVOL$a / 65536`
icon="audio-volume-medium"
notify-send -t 1000 -i $icon "Mute: off"
exit
fi
fi
# a=00
# p=`expr $CURVOL$a / 65536`
# icon="audio-volume-low"
# if [[ $CURVOL -ge 50000 ]]
# then
# icon="audio-volume-high"
# elif [[ $CURVOL -ge 30000 ]]
# then
# icon="audio-volume-medium"
# fi
#echo $CURVOL
pactl set-sink-volume 1 $CURVOL
echo $CURVOL > ~/.pulse/volume # Write the new volume to disk to be read the next time the script is run.
# notify-send -t 500 -i $icon "$p%"
#!/bin/sh cd /home/manu/Config/bin/Alarmaniac/ java -jar alarmaniac.jar
#! /bin/bash echo "----------------------- BEGIN KEYBOARD SETUP ---------------------------" setxkbmap -option compose:ralt echo "----------------------- END KEYBOARD SETUP ---------------------------"
#! /bin/sh
for i in *.pdf ; do
echo ""
echo "-------------------------------------------------------------------------";
filebase=${i%.*};
INFO=`pdfinfo "$"i 2>/dev/null`;
FIRSTPAGE=`pdftotext -f 1 -l 1 "$i" -|head -c 1000|tr -d '[*]'`;
Title=`echo $INFO| awk -F ":" '/Title/ {print $2}'`
Author=`echo $INFO| awk -F ":" '/Author/ {print $2}'`
Subject=`echo $INFO| awk -F ":" '/Subject/ {print $2}'`
Date=`echo $FIRSTPAGE|grep -E -o --color=none "(18|19|20)[0-9]{2}"|xargs|cut -c 1-4`
### Display information
echo File is : ${i%.*};
echo Title: $Title
echo Author: $Author
echo Subject: $Subject
echo Date: $Date
### Predifined scheme
title=" - $Date - "`pdftotext -f 1 -l 1 "$i" - | tr -d '[*]'| awk '!/[0-9.]/'|awk '/. / '|tr '\n' ' '|head -c 100`
titleRis1=" - $Date - "`pdftotext -f 1 -l 1 "$i" - |tr -d '[*]'|awk '!/Ris/'|awk '/. /'|awk '!/[,]/' |tr '\n' ' '|head -c 100`
titleRis2=" - $Date - "`pdftotext -f 1 -l 1 "$i" - |tr -d '[*]'| awk '!/Ris/' |awk '/[A-Za-z0-9.]/'| awk '/. /'|awk '!/[,]/' |tr '\n' ' '|head -c 100`
titlesandia=" - $Date - "`pdftotext -f 1 -l 1 "$i" - |tr -d '[*]'| awk '!/[0-9.]/'|awk '!/SANDIA REPORT/' |awk '!/Unlimited Release/' |awk '/. / '|tr -d '\n' |head -c 100`
titlebegin=" - $Date - "`echo $FIRSTPAGE|cut -c 100`
titleupper=" - $Date - "`echo $FIRSTPAGE|grep -E -o --color=none "[A-Z]{2}[A-Z]*" |xargs |cut -c 1-100`
titleECN=`pdftotext -f 1 -l 1 "$i" - | awk '!/[0-9.]/'|awk '/. / '|tr '\n' ' '|head -c 64|tr ' ' '_'`
### Making a choice
nchosen=1;
if test "`echo $FIRSTPAGE|cut -c -11`" = "WIND ENERGY"
then
echo "Wind Energy Publication"
Date=`pdftotext -f 1 -l 1 "$i" - |awk -F "Published" 'NR < 2 {print $2}'|grep -E -o --color=none "(18|19|20)[0-9]{2}"`
Title=`pdftotext -f 1 -l 1 "$i" -|awk 'NR==5 {print $0}'`
Author=`pdftotext -f 1 -l 1 "$i" -|awk 'NR==6 {print $0}'|tr -d '[:punct:]'|cut -c 1-30`
titlechosen="$Author - $Date - $Title"
nchosen=5
elif test "`echo $FIRSTPAGE|cut -c -11`" = "ECN"
then
titlechosen=titleECN
nchosen=8
elif [ -n "`echo $Subject|grep "Journal"`" ]
then
echo "JOURNAL OF FLUID MEACHANICS"
Year=`echo $INFO| awk -F ":| " '/CreationDate/ {print $NF}'`
titlechosen=$Author" - "$Year" - "$Title
nchosen=5b
elif [ -n "`echo $FIRSTPAGE|grep "Ris"`" ]
then
echo "RISO INSIDE"
if [ `expr length "$titleRis1"` -gt 12 ]
then
titlechosen=$titleRis1
nchosen=2;
else
titlechosen=$title
nchosen=1;
fi
elif [ -n "`echo $FIRSTPAGE|grep "SANDIA"`" ]
then
echo "SANDIA INSIDE"
titlechosen=$titlesandia
nchosen=4
elif [ -n "`echo $Subject|grep "Journal"`" ]
then
echo "JOURNAL OF FLUID MEACHANICS"
Year=`echo $INFO| awk -F ":| " '/CreationDate/ {print $NF}'`
titlechosen=$Author" - "$Year" - "$Title
nchosen=5b
elif [ -n "$Title" ]
then
titlechosen=$Title;
nchosen=5;
else
titlechosen=$title;
nchosen=1;
fi
if [ `expr length "$title"` -lt 7 ]
then
nchosen=0;
titlechosen="$filebase"
fi
titlepdfinfo=$Author" - $Date - "$Title
### User interact
echo "- Choices :"
echo 1 - $title
echo 2 - $titleRis1
echo 3 - $titleRis2
echo 4 - $titlesandia
echo 5 - $titlepdfinfo
echo 6 - $titlebegin
echo 7 - $titleupper
echo 8 - $titleECN
echo ""
echo "$nchosen)->"$titlechosen
echo ""
echo "-Type enter for default, number for choice, 0 for nothing"
read choice
if [ -n "$choice" ]
then
echo "Using choice $choice"
case $choice in
0) dest="$filebase";;
1) dest="$title" ;;
2) dest="$titleRis1" ;;
3) dest="$titleRis2" ;;
4) dest="$titlesandia" ;;
5) dest="$titlepdfinfo" ;;
6) dest="$titlebegin";;
7) dest="$titleupper" ;;
8) dest="$titleECN" ;;
esac
else
echo "Using default:"
dest=$titlechosen
fi
# echo "mv $i $dest"
mv "$i" "$dest.pdf"
done
#!/bin/bash
#############################################################
# unix2win:
#############################################################
# Description : mv input files from unix format to windows compatible format
# Written by : Emmanuel Branlard
# Date : May 2011
# Dependencies :
# License : Feel free to modify and adapt it
# Example :
# find ./* -type f -execdir unix2win {} \;
#############################################################
#############################################################
for file ;
do
newfile=`echo $file | sed -e 's/[^a-Z_0-9\. /-]//g' ;`
if [[ "$file" != "$newfile" ]]
then
echo $file ;
echo $newfile ;
mv "$file" "$newfile" ;
fi
done
#!/bin/sh
#~
#~ cd Debianuel
#~ cp -r debianuel debianuel-bkp
#~
#~ cd debianuel
#~
#~
#~ rename "s/html/php/g" *.php
#~ sed -i "s/[.]html/.php/g" *.php
#~ sed -i "s:</HEAD>::g" *.php
#~
#~
#~ old_value="<BODY >";
#~ new_value="<? include('../_includes/haut.php');?>";
#~ sed -i "s:$old_value:$new_value:g" *.php
#~
#~ old_value="<ADDRESS>";
#~ new_value="<? include('../_includes/bas.php'); ?>";
#~
#~ sed -i "s:$old_value:$new_value:g" *.php
#~
#~
#~ old_value="</ADDRESS>";
#~ new_value="";
#~ sed -i "s:$old_value:$new_value:g" *.php
#~
#~
#~
#!/bin/sh #initialization HOME=/home/manu folder=/home/manu/Config/scripts/Bootchart mydate=$(date +%Y-%m-%d-%H%M) cd $HOME bootchart cp bootchart.png $folder/bootchart$mydate.png
#!/bin/bash
# echo "----------------------- BEGIN TERMINATOR ---------------------------"
# #x=`xrandr --query |grep 2720 |wc -l`; #home
# # sleep 5
# echo "----------------------- BEGIN TERMINATOR ---------------------------"
# x=`xrandr --query |grep 3360 |wc -l`; #riso
# if [[ $x > 0 ]]
# then
# terminator --geometry +2000 -m -l 4terms
/home/manu/Config/builds/terminator/terminator-0.95/terminator --geometry +2000 -m -l 4terms
# else
# terminator -m -l 4terms
# fi
# Screen 0: minimum 2720 x 1024, current 2720 x 1024, maximum 2720 x 1024
# default connected 2720x1024+0+0 0mm x 0mm
# 2720x1024 50.0*
#!/bin/bash ################################################# # WHAT is svg2png ? # Script to convert svg files to png # svg2png does not modify the file which you select, it creates a new file. # It cannot convert a directory but you can select several files. ################################################# # INFO # Author : yeKcim - yeknan@yahoo.fr - http://yeknan.free.fr # Licence : GNU GPL # Dependency # zenity # inkscape # Based on # WOM_audioconverter # History # 15.01.2006 : v0.1 : First public version # Install # Put on ~/.gnome2/nautilus-scripts/ # In a console : chmod u+x ~/.gnome2/nautilus-scripts/svg2png version="0.1" ################################################# # TRADUCTIONS ###### Default = English ##### title="svg2png "$version"" pleasesel="Please select at least one file." noselec=""$title" converts svg to png. "$pleasesel"" nobin="Program inkscape is not installed, please install !" warning="Warning" choix="Export type ?" drawing="Drawing" canvas="Canvas" exportof="Picture to convert :" case $LANG in ######## Français ######## fr* ) title="svg2png "$version"" pleasesel="Merci de sélectionner au moins un fichier." noselec=""$title" permet de convertir des svg en png. "$pleasesel"" warning="Attention" nobin="Le programme inkscape n'est pas installé, veuillez l'installer !" choix="Type d'export ?" drawing="Dessin" canvas="Page" exportof="Image à convertir :" ;; esac ################################################# # PROGRAMME ######## Test dépendance ######## which inkscape 2>/dev/null if [ $? != 0 ] then zenity --error --title="$title" --text="$nobin" exit 0 fi #### Pas de fichiers sélectionné ### if [ $# -eq 0 ]; then zenity --error --title="$warning" --text="$noselec" exit 1 fi ######## Page/image ? ######## while [ ! "$choixutilisateur" ] # Réafficher la fenêtre tant que l'utilisateur n'a pas fait de choix do choixutilisateur=`zenity --title "$title" --list --column="$exportof" $canvas $drawing --text "$choix"` ###### Choix -> Sortie boucle ###### if [ $? != 0 ]; then exit 1 fi [ $? -ne 0 ] && exit 2 # Annulation done if [ $choixutilisateur == $drawing ]; then type="--export-area-drawing"; fi ######## Résolution ? ######## while [ ! "$resolution" ] # Réafficher la fenêtre tant que l'utilisateur n'a pas fait de choix do resolution=`zenity --entry --title "$title" --text "Résolution :" --entry-text "90"` ###### Choix -> Sortie boucle ###### if [ $? != 0 ]; then exit 1 fi [ $? -ne 0 ] && exit 2 # Annulation done ######## Export png ######## while [ $# -gt 0 ]; do picture=$1 png_file=`echo "$picture" | sed 's/\.\w*$/.png/'` inkscape $type --export-dpi="$resolution" --export-png="$png_file" "$picture" shift done
#! /usr/bin/env python
#
# Convert an M3U playlist to XSPF.
#
# Usage: m3u2xspf < input.m3u > output.xspf
#
# Copyright (c) 2006, Matthias Friedrich <matt@mafr.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
__revision__ = '$Id: m3u2xspf,v 1.4 2007/03/30 16:31:03 matthias Exp matthias $'
__version__ = '0.2'
import sys
import urllib
import urlparse
import os.path
import optparse
import xml.sax.saxutils as saxutils
class XmlWriter(object):
def __init__(self, outStream, indentAmount=' '):
self._out = outStream
self._indentAmount = indentAmount
self._stack = [ ]
def prolog(self, encoding='UTF-8', version='1.0'):
pi = '<?xml version="%s" encoding="%s"?>' % (version, encoding)
self._out.write(pi + '\n')
def start(self, name, attrs={ }):
indent = self._getIndention()
self._stack.append(name)
self._out.write(indent + self._makeTag(name, attrs) + '\n')
def end(self):
name = self._stack.pop()
indent = self._getIndention()
self._out.write('%s</%s>\n' % (indent, name))
def elem(self, name, value, attrs={ }):
# delete attributes with an unset value
for (k, v) in attrs.items():
if v is None or v == '':
del attrs[k]
if value is None or value == '':
if len(attrs) == 0:
return
self._out.write(self._getIndention())
self._out.write(self._makeTag(name, attrs, True) + '\n')
else:
escValue = saxutils.escape(value or '')
self._out.write(self._getIndention())
self._out.write(self._makeTag(name, attrs))
self._out.write(escValue)
self._out.write('</%s>\n' % name)
def _getIndention(self):
return self._indentAmount * len(self._stack)
def _makeTag(self, name, attrs={ }, close=False):
ret = '<' + name
for (k, v) in attrs.iteritems():
if v is not None:
v = saxutils.quoteattr(str(v))
ret += ' %s=%s' % (k, v)
if close:
return ret + '/>'
else:
return ret + '>'
def createAnnotation(url):
"""Get file name part, split off extension, rewrite underscores."""
path = urllib.unquote(urlparse.urlsplit(url)[2])
filename = os.path.splitext(os.path.basename(path))[0]
return filename.replace('_', ' ')
#
# MAIN
#
optParser = optparse.OptionParser(
usage='%prog [-ah] [file]',
version='%prog ' + __version__
)
optParser.add_option('-a', '--annotation',
action='store_true', dest='add_annotation',
default=False, help='create annotation elements based on the file name')
(options, args) = optParser.parse_args()
#
# Write the playlist in XSPF format.
#
xml = XmlWriter(sys.stdout, indentAmount=' ')
xml.prolog()
xml.start('playlist', { 'xmlns': 'http://xspf.org/ns/0/', 'version': '1' })
xml.start('trackList')
for line in sys.stdin:
line = line.rstrip('\n')
if line.startswith('#') or len(line.strip()) == 0:
continue
if line.startswith('http://'):
url = line
else:
url = 'file://' + urllib.pathname2url(line)
xml.start('track')
xml.elem('location', url)
if options.add_annotation:
xml.elem('annotation', createAnnotation(url))
xml.end() # track
xml.end() # trackList
xml.end() # playlist
# EOF
#!/bin/bash
#############################################################
# To MP3
#############################################################
# Description : au2mp3 m4a2mp3 wma2mp3 mp32mp3 flv2mp3 anything2mp3
# Written by : Emmanuel Branlard
# Date : Feb 2011
# Dependencies : ffpmeg, lame, sox, faad ,mplayer
# License : Feel free to modify and adapt it
#############################################################
for i
do
# Out File
j=`echo "$i"|tr '_' ' '`
j=${j%.*}.mp3
echo "File $j"
if [ -f "$j" ]
then
echo "File exists $j -> skipping"
else
echo "File does not exists"
if [[ "$i" == *.au ]]
then
sox "$i" "$i".wav
ffmpeg -i "$i".wav -vn -acodec libmp3lame -y "$j"
rm "$i".wav
elif [[ "$i" == *.m4a ]]
then
faad -o - "$i" | lame -h -b 192 - "$j"
elif [[ "$i" == *.wav ]]
then
lame "$i" "$j"
elif [[ "$i" == *.wma ]]
then
#wma > mp3 Rip with Mplayer / encode with LAME
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$i" ;
lame "audiodump.wav" "$j";
rm "audiodump.wav"
elif [[ "$i" == *.mid* ]]
then
#
echo To be done
elif [[ "$i" == *.mp3 ]]
then
#mp3 > mp3
lame "$i" "audiodump.mp3"
mv "audiodump.mp3" "$j"
else
echo "Format unknown" ;
ffmpeg -i "$i" -vn -ab 128k -ac 2 -ar 44100 -y "$j">/dev/null ;
fi
fi
done
#! /bin/bash
for i in *.pdf ; do
echo ""
echo "-------------------------------------------------------------";
echo ${i%.*};
title=`pdftotext -f 1 -l 1 $i - | awk '!/[0-9.]/'|awk '/. / '|tr '\n' ' '|head -c 64|tr ' ' '_'`
mv "$i" "${i%.*}_$title.pdf"
done
#!/usr/bin/python
import os, string
marker = 0
marker2 = 0
orderlist = []
a = open( 'playlists.xml', 'r' )
if not os.path.exists("playlists"):
os.makedirs("playlists")
os.chdir("playlists")
z = open( 'order_file', 'w' )
for line in a.xreadlines():
if marker == 1:
if line.find('<location>') != -1 and line.rfind('</location>') != -1:
line = line[line.find('<location>')+10:]
line = line[:line.find('</location>')]
line = string.replace( line, '&', '&' )
if marker2 == 0:
m = open( name+'.playlist', 'w' )
z.write(name+'\n')
marker2 = 1
m.write(line+'\n')
elif line.find('</playlist>') != -1:
if marker2 == 0:
continue
m.write('EOF\n')
m.write('random_enabled=B: False\n')
m.write('random_mode=S: track\n')
m.write('repeat_enabled=B: False\n')
m.write('repeat_mode=S: playlist\n')
m.write('dynamic_enabled=B: False\n')
m.write('current_pos=I: -1\n')
m.write('name=U: '+name+'\n')
m.write('_is_custom=B: True\n')
m.write('_needs_save=B: False\n')
m.close()
marker = 0
marker2 = 0
elif line.find('<playlist name="') != -1:
if line.rfind('/>') == -1:
line = line[line.find('<playlist name="')+16:]
line = line[:line.find('"')]
line = string.replace( line, '&', '&' )
name = line
marker = 1
a.close()
z.write('EOF\n')
z.close()
#! /bin/sh #launching rhythmbox& #after a while using the client to play sleep 2;rhythmbox-client --play --hide&
#! /bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
echo "Converting pdfs "
for i in `find -name "*.php" -printf '%h/%f\n' 2> /dev/null`
do
echo "----------------------------"
echo "Keywords $i";
echo "----------------------------"
cp $i "$i.tmp"
cat "$i.tmp" | awk '$0 !~ NAME="keywords" {print $0}; $0 ~ NAME="keywords" {print "<META NAME=\"keywords\" CONTENT=\"KEYWORDSSHOULDGOHERE\">"}' >$i
rm "$i.tmp"
done;
IFS=$SAVEIFS
#!/usr/bin/python
import dbus
import time
#import os
import signal, sys
if len(sys.argv) != 3 :
sys.stderr.write('Usage: pm-inhibit.py <appname> <reason>\n')
sys.exit(1)
def sighandler(signum, frame) :
dev.UnInhibit(cookie)
exit()
bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
devobj = bus.get_object('org.freedesktop.PowerManagement', '/org/freedesktop/PowerManagement/Inhibit')
dev = dbus.Interface (devobj, "org.freedesktop.PowerManagement.Inhibit")
cookie = dev.Inhibit(sys.argv[1], sys.argv[2])
# going away from dbus when dieing should be enough, but be sure
signal.signal(signal.SIGTERM, sighandler)
print cookie
while 1 == 1 :
time.sleep(30)
#! /bin/bash
if [ $# -eq 0 ]
then
Files=*.pdf
Files="$Files"
else
l=$@
Buff=""
First=''
for i in $l
do
if [ ! `echo $i |grep -E "[.][a-zA-Z]{3,4}$"` = "" ]
then
File="$Buff $i"
Buff=""
First=""
File2=`echo $File|tr ' ' '_'`
#
if [ $File != $File2 ]
then
mv "$File" $File2
fi
#
Files="$Files $File2"
else
if [ -z ${First} ]
then
Buff="$i"
First="no"
else
Buff="$Buff $i"
fi
fi
done
# echo $Files
fi
FileOut=`echo $Files|grep -Eo "^[a-Z0-9\_ -]*[.]"|tr '_' ' '`"Bind.pdf"
echo $FileOut
pdftk $Files cat output "$FileOut"
#!/bin/bash
unalias grep
########################################################################
# Preliminary tests
########################################################################
if [ $# == 0 ]
then
echo "No arguments !";
exit;
fi
cpt=`ls /usr/bin 2>/dev/null |grep gawk|wc -l`
if [ $cpt == 0 ]
then
echo "Install gawk !";
exit;
fi
cpt=`ls /usr/bin 2>/dev/null |grep latex2html|wc -l`
if [ $cpt == 0 ]
then
echo "Install latex2html !";
exit;
fi
#
echo "Entering folder $1"
cd $1
#
echo "Trying *report*.tex"
cpt=`ls *eport*.tex 2>/dev/null|wc -l`
echo $cpt
if [ $cpt -ne 1 ]
then
if [ $cpt -gt 0 ]
then
ls *eport*.tex
echo "Ambiguity on the main file name !"
exit;
else
echo "Trying *.tex"
cpt=`ls *.tex 2>/dev/null|wc -l`
echo $cpt
if [ $cpt -ne 1 ]
then
ls *.tex
echo "Ambiguity on the main file name !"
exit;
else
f=`echo *.tex`;
fi
fi
else
f=`echo *eport*.tex`;
fi
echo ""
echo "Main file: $f"
cp $f ${f/tex/backuptex}
title=`grep titlea $f |awk -v FS="[{}]" '{print $4}' | xargs`
echo "Title: $title\n"
echo ""
echo "Press ENTER if every thing's OK , Ctrl+C otherwise"
read
########################################################################
# Removing pdf
########################################################################
echo "##################################################################"
echo "Converting pdf to png"
echo "##################################################################"
rm *.pdf 2>/dev/null
../pdf2pngCleanUp
########################################################################
# latex work
########################################################################
echo "##################################################################"
echo "Formatting"
echo "##################################################################"
echo "Modifying figure width"
grep -nHFR \\\newcommand{\\\fitfig} ./* > tmp.tmp
ff=`gawk -F: '{print $1}' tmp.tmp`
if `test -e $ff`
then
sed -i "s/{\\\fitfig}\[1\]{[#0-9\\\a-zA-Z]*}/{\\\fitfig}[1]{14cm}/g" $ff
fi
echo "Commenting xcolor"
grep -nHR .*{xcolor} ./* > tmp.tmp
ff=`gawk -F: '{print $1}' tmp.tmp`
if `test -e $ff`
then
sed -i "s/.*usepackage.*{xcolor}*/%\\\usepackage[table]{xcolor} /g" $ff
fi
echo "Modifying for parshape"
grep -nHR .*\\\parshape ./* > tmp.tmp
ff=`gawk -F: '{print $1}' tmp.tmp`
if `test -e $ff`
then
sed -i "s/.*\\\parshape/%/g" $ff
fi
rm tmp.tmp
echo "Modifying $f for undefined commands before \begin{document}"
old_value=".*\\\begin{document}";
new_value="\\\newcommand{\\\rowcolors}[3]{} \\\renewcommand{\\\arrayrulecolor}[1]{} \\\renewcommand{\\\rhead}[1]{} \\\renewcommand{\\\hypersetup}[1]{} \\\renewcommand{\\\lstset}[1]{} \\\renewcommand{\\\framebox}[1]{#1} \\\renewcommand{\\\script}[1]{} \\\renewcommand{\\\command}[1]{} \\\renewcommand{\\\dtutext}[1]{#1\\\par} \\\begin{document}";
sed -i "s/$old_value/$new_value/g" $f
echo "##################################################################"
echo "Running pdflatex a first time on $f"
echo "##################################################################"
pdflatex $f
echo "##################################################################"
echo "Running bibtex on $f"
echo "##################################################################"
ff=*.aux
bibtex $ff
echo "##################################################################"
echo "Running pdflatex a second time on $f"
echo "##################################################################"
pdflatex $f
########################################################################
# latex 2 html and postformatting
########################################################################
echo "##################################################################"
echo "Now Running latex2html"
echo "##################################################################"
echo "Running latex2html on folder $1"
latex2html -html_version 4.0,ISO-8859-1 -address " " -split 2 $f -dir $1 -mkdir -t "$title"
echo "Done. If results are bad, check that the package xcolor has been commented."
echo "Formatting"
cp -r $1 "$1-bkp"
cd $1
rename "s/html/php/g" *.php
sed -i "s/[.]html/.php/g" *.php
sed -i "s:</HEAD>::g" *.php
old_value="<BODY >";
new_value="<? include('../_includes/haut.php');?>";
sed -i "s:$old_value:$new_value:g" *.php
old_value="<ADDRESS>";
new_value="<? include('../_includes/bas.php'); ?>";
sed -i "s:$old_value:$new_value:g" *.php
old_value="</ADDRESS>";
new_value="";
sed -i "s:$old_value:$new_value:g" *.php
old_value="</ADDRESS>";
new_value="";
sed -i "s:$old_value:$new_value:g" *.php
########################################################################
# Keywords
########################################################################
echo "##################################################################"
echo "Keywords"
echo "##################################################################"
keywords=`cat *php* | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | tr ' ' '\n' | tr -d '[:punct:]' | grep -v '[^a-z]'| grep -E '[a-z]{3,}' | tr '[:upper:]' '[:lower:]' | grep -v -w -E 'the|and|for|from|with|used|which|are|that|this|will|can|been|should|using|all|one|two|three|has|taken|where|made|also|thus|though|have|when|not|such|figure|table|these|could|seen|given|nbsp|les|des|from|different|est|dans|une|our|qui|between|next|would|sont|its|see|son|plus|case|que|pour|suivant|nous|par|sur|each|but|than|only|other|main|figures|tables|more|there|value|values|were|was|low|high|around|since|very|order|per|into|first|because|found|them|done|good|their|really|here|got|big|better|well|away|shown|over|like|while|within|take|due|any|then|under|same|much|most|both|second|lot|use|get|pas|mais|alors|peut|plot|left|right' | sort | uniq -c| sort -rn|head -50 |sed 's/'[\ 0-9]'//g' |xargs |sed 's/[\ ]/,/g' `
echo "Keywords: $keywords"
../../keywordsSetUp.sh
old_value='KEYWORDSSHOULDGOHERE';
new_value="$keywords";
sed -i "s:$old_value:$new_value:g" *.php
cd ../
#final cleaning
texclean 2>/dev/null
#!/bin/bash
if [ $1 = "vortex" ]; then
DIR="/work/publications/notes/"
thunar "$DIR";
gvim -S "$DIR""SessionVortex.vim"
fi
if [ $1 = "vortexcode" ]; then
DIR="/work/VortexCode/VortexElements/"
thunar "$DIR";
gvim -S "$DIR""Session.vim"
fi
if [ $1 = "momentum" ]; then
DIR="/work/publications/notes/"
thunar "$DIR";
gvim -S "$DIR""SessionMomentum.vim"
fi
if [ $1 = "book" ]; then
DIR="/work/publications/book/"
thunar "$DIR";
gvim -S "$DIR""Session.vim"
fi
#! /bin/sh #launching rhythmbox& #after a while using the client to play sleep 20;rhythmbox-client --play --hide&
#!/bin/bash
#
# Conversion de toute une arborescence d'un encodage dans un autre.
# Exemple d'utilisation :
# mise a jour de sa distribution Linux de iso-8859-1 vers UTF-8
#
# Necessite : convmv et iconv
#
# Utilisation :
# $ ./convertEnc.sh Documents/Divers
#
# IMPORTANT : faites une copie de vos donnees et travaillez sur cette copie !!
# (Je ne peux etre tenu responsable si vous corrompez vos donnees, soyez prudents)
#
# Ce script ne demande qu'a etre ameliore...
#
## Protection contre les espaces (JacquesF -> guillemets autour des variables ou cela n'etait pas fait)
#
# Sebastien de Boissieu (c) 2006
# $Id: convertEnc.sh,v 1.8.2.1 2007/03/17 22:39:29 sebastien Exp $
# Licence : GPL 2
FROM="iso-8859-1"
TO="UTF-8"
echo "Conversion de $FROM en $TO"
# Procedure pour renommer un fichier si nom deja existant
renomme()
{
nbe=0
num="_$nbe"
nouvnom="$1"
while [ -e "$nouvnom" ];
do
let nbe=nbe+1
num="_$nbe"
nouvnom="$1$num"
done
export nouvnom
}
# Conversion recursive des noms de fichiers et repertoires
convert_names()
{
echo "Conversion des NOMS de fichiers et repertoires"
#convmv -r -f $FROM -t $TO --qfrom --qto --notest "$1"
convmv -r -f $FROM -t $TO --notest "$1"
echo ""
}
# Routine de conversion du contenu d'un fichier
do_convert()
{
fic="$1"
echo " Fichier $fic"
# Lecture du type mime
encForm=`file -bi "$fic" | awk -F "charset=" '{ print $2 }'`
if [ ! "$encForm" = "" ]; then
# le fichier possede un charset
echo " -> $encForm"
if [ ! "$encForm" = "$TO" ]; then
# ce charset est different de celui vise
# nom du fichier converti temporaire
renomme "$fic"_"$TO"
nouv_fic="$nouvnom"
# la conversion
iconv -f "$encForm" -t $TO "$fic" -o "$nouv_fic"
# reussite ou echec de la commande cruciale ?
status=$?
if [ $status == 0 ]; then
# Pour conserver la/les date(s) :
touch -r "$fic" "$nouv_fic"
# Pour conserver le proprietaire
chown --reference "$fic" "$nouv_fic"
# pour conserver les droits :
chmod --reference "$fic" "$nouv_fic"
# on ecrase l'ancien fichier par le nouveau
if [ -w "$fic" ] ; then
### JacquesF
### Sur mes tests, si le fichier n'est pas accessible en ecriture
### un mv -f sur le fichier remplace pourtant celui-ci (droits d'ecriture dans le repertoire)
mv -f "$nouv_fic" "$fic"
else
echo "Le fichier $fic n'est pas accessible en ecriture"
echo "Le fichier converti se nomme $nouv_fic"
fi
else
echo " -> Echec: $nouv_fic corrompu ?"
echo " $fic conserve."
fi
fi
fi
}
# Conversion recursive du contenu des fichiers texte
convert_content()
{
#echo "Conversion du contenu des fichiers"
if [ -d "$1" ]; then
# c'est un repertoire
if [ -x "$1" ]; then
# On peut entrer dans le repertoire
echo "Entree dans : $1"
### Protection si le repertoire contient un espace
chemin_orig="`pwd`"
cd -- "$1"
# liste complete (avec fichiers caches)
# Attention : si liste trop longue ca peut planter
# passer par xargs --> man xargs
for fic in `ls * .* | xargs` ; do
if [ $fic != "." -a $fic != ".." ]; then
base_fic=$(basename -- "$fic")
#echo "$fic -> $base_fic"
echo " Analyse de : $base_fic"
# recursivite
if [ -d "$base_fic" ]; then
# Si repertoire, on execute la procedure dessus
convert_content "$base_fic"
else
# sinon on fait la conversion
do_convert "$base_fic"
fi
fi
done
echo "Sortie de : $1"
cd "$chemin_orig"
else
echo "Entree INTERDITE dans : $1"
fi
else
# On fait la conversion sur le fichier
do_convert "$1"
fi
}
#=======================================
# Debut execution
if [ $# -gt 0 ]; then
### Alerte avant lancement du script
clear
echo -e "\n\nATTENTION : ne travaillez jamais sur les donnees d'origine !"
echo -e "\nEtes-vous certain de vouloir modifier ces fichiers ?"
echo -e "\tAppuyez sur Ctrl-C pour annuler ou sur Return pour continuer \c"
read Tempo
echo
### Fin de l'alerte
# pour l'instant on ne considere que le 1er argument
echo "Sur: $1"
echo ""
### On n'est pas a l'abri d'un repertoire avec des espaces dans le nom
convert_names "$1"
echo "============="
# Remarque : si $1 est un repertoire dont le nom a ete converti
# le contenu de $1 est obsolete.
# on le converti :
nom=$(echo "$1" | iconv -f $FROM -t $TO)
convert_content "$nom"
echo "Fini"
else
echo "Utilisation :"
echo "$0 chemin/repertoire"
### Alerte par precaution
echo "Ne travaillez jamais sur les donnees d'origine mais seulement sur une copie de celles-ci"
fi
#!/bin/sh ############################################################# # Altern Rotation : ############################################################# # Rotate by 180 degrees every other page of a pdf # written by Emmanuel Branlard # Oct 2009 # This script uses pdftk # Feel free to modify and adapt it # To separate 'file.pdf' into single page files : # pdftk file.pdf burst ############################################################# echo 'Every other pdf file in the current directory will be rotated' echo 'Warning : do a backup of the pdf files first' echo ' Press Ctrl+C to cancel' echo ' Press Enter to Continue'; read reply j=0 # looping on all pdf files in the folder for i in *.pdf ; do j=`expr $j + 1`; printf 'File %d : %s ' $j $i if [ `expr $j % 2` -eq 0 ]; then printf ' -> Rotating... '; cp $i $i.bkp pdftk $i.bkp cat 1S output $i rm $i.bkp fi echo '' done echo 'Do you want to concatenate the file ?' echo ' Press Ctrl+C to cancel' echo ' Press Enter to Continue'; read reply echo 'Binding...' pdftk *.pdf cat output bind.pdf echo "Done. File 'bind.pdf' created"
#!/bin/sh xfce4-terminal -T T4 --geometry 80x26+800+450 & xfce4-terminal -T T1 --geometry 80x26+84+0 & xfce4-terminal -T T3 --geometry 80x26+800+0 & xfce4-terminal -T T2 --geometry 80x26+84+450 &
#!/bin/bash pywo put -p $1 pywo put -p M --xinerama
#!/bin/bash
echo "----------------------- BEGIN SCREENCONF ---------------------------"
sleep 3
echo "----------------------- BEGIN SCREENCONF ---------------------------"
#x=`xrandr --query |grep 2720 |wc -l`; #home
x=`xrandr --query |grep 1920 |wc -l`; #riso
echo "x:"$x
if [[ $x > 0 ]]
then
#/home/manu/Config/profiles/screenlayout/RisoScreenPersoLaptop.sh
xrandr --output LVDS-1 --mode 1440x900 --pos 1920x0 --rotate normal --output VGA-1 --mode 1920x1080 --pos 0x0 --rotate normal
fi
#include <X11/extensions/XTest.h>
#include <X11/keysym.h>
/*
Requires:
aptitude install libxcb-keysyms1-dev libxtst-dev
Compiled with:
gcc -I/usr/include/X11 -L/usr/lib/X11 -o xsetnumlock xsetnumlock.c -lX11 -lXtst */
int main(void)
{
Display* disp = XOpenDisplay(NULL);
if (disp == NULL) return 1;
XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Num_Lock),
True, CurrentTime);
XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Num_Lock),
False, CurrentTime );
XCloseDisplay(disp);
return 0;
}
#! /bin/sh
#############################################################
# Ref
#############################################################
# Description : uses locate to search through references
# Written by : Emmanuel Branlard
# Date : Dec 2011
# Dependencies :
# License : Feel free to modify and adapt it
# Use: ref Word1 Word2 etc.
#############################################################
a="";
for i
do
a=$a" "$i;
b=$b"|"$i;
done
# locate -iA $a |grep --colour=never _Refs|cut -b 13-|grep --colour=auto -i -E "$b"
locate -iA $a |grep --colour=never _Refs|grep --colour=auto -i -E "$b"
#!/bin/bash ############################################################# # Default script: ############################################################# # Description : # Written by : Emmanuel Branlard # Date : Oct 2009 # Dependencies : # License : Feel free to modify and adapt it # Note : To separate 'file.pdf' into single page files : # pdftk file.pdf burst ############################################################# echo "Script name is [$0]" echo "This Process ID is [$$]" echo "This Parameter Count is [$#]" echo "All Parameters [$@]" echo "The FLAGS are [$-]" ############################################################# #sh syntax # if [ $# -eq 0 ]; then echo "No arguments"; fi # Expression comparison : !EX1 -a Ex2, Ex1 -o Ex2 # String comp : S1 = S2, S1!=S2 # Int comp : I1 -ne I2 #bash syntax #if [ $# == 0 ]; then echo "No arguments"; fi # for f in * # do # echo "$f" # done