viernes, 15 de abril de 2016

Dual Monitor in LXDE

La clau està en instal·lar el arandr. Informació general aquí.

I created two scripts in the .screenlayout/ directory with the help of ARandR:



~/.screenlayout$ cat single.sh 
#!/bin/sh
xrandr --output LVDS1 --mode 1024x600 --pos 0x0 --rotate normal --output VGA1 --off
lxpanelctl restart

~/.screenlayout$ cat dual.sh 
#!/bin/sh
xrandr --output LVDS1 --mode 1024x600 --pos 0x0 --rotate normal --output VGA1 --mode 1920x1080 --pos 1024x0 --rotate normal
lxpanelctl restart

adding the string "lxpanelctl restart" by hand (ARandR doesn't do it). Then, in the file
~/.config/openbox/lxde-ec.xml
I added the following lines between two </keybind> lines:


Code:
  </keybind>
  <keybind key="W-2">
  <action name="Execute">
  <command>sh ~/.screenlayout/dual.sh</command>
  </action>
  </keybind>
  <keybind key="W-1">
  <action name="Execute">
  <command>sh ~/.screenlayout/single.sh</command>
  </action>
</keybind>

so that using <super(windws)><1> and <super(windws)><2> I can switch between single and dual monitor configuration.

I hope this will be useful for others!

martes, 12 de abril de 2016

Anomenar fitxers correlativament

Tenim una carpeta amb fitxers a.png, bbbb.png cc-cccc.png i volem tenir-los com a 001.png, 002.png, 003.png

#!/bin/bash

i=1;
for file in *.png
do
  a=$(printf "%03d" $i)
  echo "$file" "$a.png"
  mv "$file" "$a.png"
  ((i++))
done

lunes, 11 de abril de 2016

PDF que no es mostra correctament (non-embedded fonts)

Un fitxer pdf no es mostra correctament perquè hi ha una font que no està embedded. Amb aquesta ordre ghostscript pot reparar el fitxer. Una explicació molt acurada, aquí.


gs -o repaired_file.pdf -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite file.pdf

viernes, 8 de abril de 2016

Eines mikrotik

Safe mode

Safe mode is entered by pressing [CTRL]+[X]. To save changes and quit safe mode, press [CTRL]+[X] again. To exit without saving the made changes, hit [CTRL]+[D]

sábado, 2 de abril de 2016

Utilitats guifi

Baixar una pàgina web i mostrar les adreces IP que hi surten, ordenades. És un curl i dos pipes:

curl http://guifi.net/ca/MNBufalvent | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'  | sort -t . -k 3,3n -k 4,4n

i si volem eliminar duplicats, afegim -u al darrer sort:
curl http://guifi.net/ca/MNBufalvent | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'  | sort -u -t . -k 3,3n -k 4,4n

Mostrar les adreces IP d'un fitxer de text, ordenades com toca:

grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' bufalvent.txt | sort -t . -k 3,3n -k 4,4n 

Veure el tràfic que passa per l'interface antena-router

tcpdump -nnvvS




ip route add 192.168.88.0/24 dev eth0 src 192.168.88.11
ip route
ip address

Download pictures from web server

Download all pics named pic01-pic16:

wget -nd http://www.zzz.com/path/pic{01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16}.jpg

Rename these pictures from pic01 to name_pic01:
rename -n -v 's/(pic.)/name_$1/' *.jpg


Convertir fitxers ODT en PDF

Existeix l'opció manual de fer-ho. Però si n'hi ha un munt, això és útil:

for file in *.odt; do unoconv -f pdf "$file"; done

Truecrypt Ubuntu 14.04

Montar un fitxer truecrypt amb ubuntu 14.04 o posteriors, que ja no tenen l'aplicació

sudo losetup -f
---> /dev/loop0
sudo losetup /dev/loop0 DATA.CRYPT
sudo tcplay -m DATA.CRYPT -d /dev/loop0
---> passphrase  (entrar password)
---> All ok!

Manipulacions amb gràfics


Canviar colors de captures de pantalla de l'oscil·loscopi

converteix el negre en blanc
mogrify  -fill "#ffffff" -opaque "#000000" tek00016.png  

converteix el blau fosc en blanc 
mogrify  -fill "#ffffff" -opaque "#394994" tek00016.png 

converteix el blau clar en blanc
mogrify  -fill "#ffffff" -opaque "#5286e7" tek00016.png  

Convertir pdf en altres

Convertir un pdf a tiff amb una determinada densitat en dpi
convert -units PixelsPerInch -density 300 a.pdf a.tiff 

Convertir un pdf a png amb una densitat determinada i conservant el fons blanc
convert -flatten -density 600 entrada.pdf sortida.png 

Convertir svg en altres

Convertir un svg a escala de grisos
inkscape -f Figura.svg --verb EditSelectAll --verb org.inkscape.color.desaturate.noprefs --verb FileSave --verb FileQuit   

Convertir tots els svg d'un directori a png
for file in *.svg ; do convert "$file" "${file%.*}.png" ; done

Script svg2png: convertir un fitxer svg a png
#!/bin/sh
NAME=`echo "$1" | cut -d'.' -f1`
EXTENSION=`echo "$1" | cut -d'.' -f2`
inkscape $NAME.svg --export-area-page --export-dpi=300 -e $NAME.png



Script svg2pdf: convertir un fitxer svg a png
#!/bin/sh
NAME=`echo "$1" | cut -d'.' -f1`
EXTENSION=`echo "$1" | cut -d'.' -f2`
inkscape $NAME.svg -D -A=$NAME.pdf


Fer una còpia de fitxers en baixa resolució

Agafa tots els fitxers d'un directori, els canvia de resolució (dimensió màxima 800). Els nous fitxers tenen com a nom el prefix r_ més el nom original del fitxer. Útil per passar fotos a un marc digital, per fer thumbnails...
for file in `ls`; do convert -resize 800x800 -quality 80 $file r_$file; done

Canviar el tamany d'uns fitxers

Canvia de resolució (dimensió màxima 1200, respectant la rel·lació d'aspecte) tots els fitxers d'un directori
mogrify -resize 1200x1200 *