Outils pour utilisateurs

Outils du site

Panneau latéral




Ham Radio






Misc Tips


Specify proper keymap

Using setxkbmap

$ <in>setxkbmap -layout us -variant intl -options "lv3:ralt_switch_multikey"</in>

Using Hal FDIs

In /etc/hal/fdi/policy, for exemple 10-x11-input.fdi (templates are usually found in /usr/share/hal/fdi/policy/):

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
    <!-- FIXME: Support tablets too. -->
    <match key="info.capabilities" contains="input.mouse">
      <merge key="input.x11_driver" type="string">mouse</merge>
      <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
        <merge key="input.x11_driver" type="string">evdev</merge>

    <match key="info.capabilities" contains="input.keys">
      <!-- If we're using Linux, we use evdev by default (falling back to
           keyboard otherwise). -->
      <merge key="input.x11_driver" type="string">keyboard</merge>
      <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
        <merge key="input.x11_driver" type="string">evdev</merge>
      <match key="info.product" string="Dell Dell USB Keyboard">
        <merge key="input.x11_options.XkbModel" type="string">dellusbmm</merge>
      <merge key="input.x11_options.XkbOptions" type="string">lv3:ralt_switch_multikey</merge>
      <merge key="input.x11_options.XkbVariant" type="string">intl</merge>

Pass options to synpatics touchpad using Hal

Dans /etc/hal/fdi/policy/11-x11-input-synaptics.fdi:

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
    <match key="info.capabilities" contains="input.touchpad">
      <match key="info.product" contains="Synaptics TouchPad">
	<merge key="input.x11_driver" type="string">synaptics</merge>
	<!-- Arbitrary options can be passed to the driver using 
	the input.x11_options property since xorg-server-1.5. -->
	<!-- EXAMPLE:
	<merge key="input.x11_options.LeftEdge" type="string">120</merge>
      <match key="info.product" contains="AlpsPS/2 ALPS">
	<merge key="input.x11_driver" type="string">synaptics</merge>
      <match key="info.product" contains="appletouch">
	<merge key="input.x11_driver" type="string">synaptics</merge>
      <match key="info.product" contains="bcm5974">
	<merge key="input.x11_driver" type="string">synaptics</merge>
    <match key="input.x11_driver" string="synaptics">
      <merge key="input.x11_options.SHMConfig" type="string">true</merge>
      <merge key="input.x11_options.VertEdgeScroll" type="string">true</merge>
      <merge key="input.x11_options.HorizEdgeScroll" type="string">true</merge>
      <merge key="input.x11_options.CornerCoasting" type="string">true</merge>
      <merge key="input.x11_options.TapButton1" type="string">1</merge>
      <merge key="input.x11_options.TapButton2" type="string">2</merge>

      <merge key="input.x11_options.RightEdge" type="string">900</merge>
      <merge key="input.x11_options.BottomEdge" type="string">700</merge>
      <merge key="input.x11_options.EmulateTwoFingerMinZ" type="string">90</merge>
      <merge key="input.x11_options.VertTwoFingerScroll" type="string">true</merge>
      <merge key="input.x11_options.HorizTwoFingerScroll" type="string">true</merge>

Modelines for Dell 2007WFP

I just found the screen on the side of the road. Surprisingly, it works. There just appears to be an EDID-reading problem, but who cares when one can manually set the modlines?

Section "Monitor"
	Identifier	"DVI1"
	Option		"DPMS"
#			      DCF   HR   SH1  SH2  HFL  VR   SV1  SV2  VFL
	ModeLine	"1680x1050" 119.0 1680 1728 1760 1840 1050 1053 1059 1080 -HSync +VSync

This can also be done manually at run-time, using XRandR.

$ <in>xrandr --newmode  "1680x1050" 119.0 1680 1728 1760 1840 1050 1053 1059 1080 -HSync +VSync</in>
$ <in>xrandr --addmode VGA1 1680x1050</in>
$ <in>xrandr --output VGA1 --mode 1680x1050</in>

BenQ G900W

Lucky day, I also found another almost perfectly working screen the very same day. It's a BenQ G900W, with the same problem; somebody must have fried their video card. It's nominal resolution is 1440×900, let's try the same trick.

Section "Monitor"
	Identifier	"VGA1"
	Option		"DPMS"
#			      DCF   HR   SH1  SH2  HFL  VR   SV1  SV2  VFL
	ModeLine	"1440x900" 106.50 1440 1520 1672 1904 900 903 909 934 -HSync +Vsync

Restore display on Poulsbo/GMA500 after suspend

As seen here, with some syntax fixes.

$ sudo mkdir -p /usr/lib/systemd/system-sleep
$ sudo tee /usr/lib/systemd/system-sleep/99vbe-restore
vbe_savemode() {
    vbetool vbemode get > $TMPFILE
vbe_restoremode() {
    # this is a little mode complicated to handle special-casing mode 3.
    local vbemode=$(cat $TMPFILE)
    if [ "$vbemode" = "3" ]; then
        vbetool vgamode set $vbemode
        vbetool vbemode set $vbemode
if [ $1 = "pre" ]; then
elif [ $1 = "post" ]; then
    [ -O /tmp/gma500-state ] && vbe_restoremode
$ sudo chmod a+x /usr/lib/systemd/system-sleep/99vbe-restore


Quick access control with Apache

In the .htaccess file:

AuthUserFile /PATH/TO/.htpasswd
AuthName "Nice name"
AuthType Basic
<Limit GET>
    require valid-user

Create and maintain the .htpasswd file:

$ <in>htpasswd -c /PATH/TO/.htpasswd user1</in>
New password: 
Re-type new password: 
Adding password for user user1
$ <in>htpasswd /PATH/TO/.htpasswd user2</in>
New password: 
Re-type new password: 
Adding password for user user2


GTK Look and Feel by default

In $JAVA_HOME/lib/swing.properties:

# Swing properties

Recreating the Java KeyStore

If Java complains with a

Unexpected error:
javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

odds are that the $JAVA_HOME/jre/lib/security/cacerts file is empty (i.e. it's only 32 Bytes in size).

To recreate it from, say, Mozilla's list of trusted certificates, the following (tested on ArchLinux) can be done:

for FILE in /usr/share/ca-certificates/mozilla/*.crt; do
  keytool -deststorepass changeit -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -file $FILE -alias `basename ${FILE/.crt/}` -noprompt

Le minimum avec Mutt

Le .procmailrc:


Le .mutt(ng)rc:

set mbox="~/mbox"
set spoolfile="~/mbox"

Et bien mieux.


Fix UID validity problem

Sometimes, most often when the IMAP server has been reconfigured or changed, OfflineImap complains of UID validity problem. The fix is known but a bit manual. The following automates deletion of all affected folders and metadata.

$ <in>export ACCOUNT=OfflineImapAccountName</in>
$ <in>export MD=/path/to/maildir/root</in>
$ <in>for folder in `offlineimap -a $ACCOUNT -u machineui | sed -n "s/ \[acc.*//;s/.*validityproblem:Folder //p"`; do rm -r $MD/$folder ~/.offlineimap/Account-$ACCOUNT/LocalStatus/$folder ~/.offlineimap/Repository-$ACCOUNT/FolderValidity/$folder; done</in>

An alternate line, for some reason, seems to be needed in same cases.

$ <in>for folder in `offlineimap -a $ACCOUNT -u machineui | sed -n "s/ \[acc.*//;s/%0A.*//;s/.*validityproblem:Folder .*://p"`; do rm -r $MD/$folder ~/.offlineimap/Account-$ACCOUNT/LocalStatus/$folder ~/.offlineimap/Repository-$ACCOUNT/FolderValidity/$folder; done</in>

Rename IMAP folders

How to rename/move IMAP folder from ${OLDNAME} to ${NEWNAME} (those being full tree paths within the IMAP hierarchy, with dots), for an account named ${IMAP}? This assumes the shell is Bash and an OfflineImap configuration such as this (namely: IMAP separators locally mapped to slashes, and consistent repository naming).

  1. Unsubscribe from the old path and move the folder in IMAP.
  2. Subscribe to that new folder.
  3. Move ${OLDNAME} files in all three files Account-${IMAP}/LocalStatus, Repository-${IMAP} and Repository-${IMAP}Local to ${NEWNAME} in OfflineImap's status directory:
    .offlineimap$ <in>for FILE in `find . -name ${OLDNAME}`; do mv $FILE ${FILE/${OLDNAME}/${NEWNAME}}; done</in>
  4. Move the local Maildir copy:
    Maildir$ <in>mv ${OLDNAME/.//} ${NEWNAME/.//}</in>
  5. Adjust the FMD5 in the filenames (see OfflineImap's FAQ, “Why are your Maildir message filenames so long?”):
    Maildir/${NEWNAME/.//}$ <in>for FILE in `find ${NEWNAME/.//} -type f`; do</in>
    >   <in>mv ${FILE} ${FILE/`echo -n "${OLDNAME/.//}" | md5sum | cut -f 1 -d " "`/`echo -n "${NEWNAME/.//}" | md5sum | cut -f 1 -d " "`};</in>
    > <in>done</in>
  6. Sync!

Des fontes GTK de taille normale

  • mettre Xft.dpi: 100 dans ~/.Xresources
  • mettre xrdb -load ~/.Xresources dans ~/.xsession (si nécessaire)
  • redémarrer X

Peut aussi marcher:

$ <in>apt-get install xfonts-base-transcoded</in>


nfs:/data/Sources on /data/Sources type nfs (rw,rsize=32768,wsize=16384,timeo=3,retrans=5,acregmin=1,acregmax=30,acdirmin=10,acdirmax=60,retry=1000,namlen=255,port=2049,mountprog=100005,nfsprog=100003,posix,bg,hard,intr,noac,udp,addr=
lambda-d5.mtek.chalmers.se:/lfs/d5.dd/mehani on /chalmers/users/mehani type nfs (rw,nosuid,hard,intr,grpid,proto=tcp,addr=

Monter une image Qemu

$ <in>mount -oloop,offset=sector_size*partition_start -t vfat /opt/qemu/tempImage /mnt/tempImage</in>

En général sector_size=512 et partition_start=63.

Pour être sûr:

$ <in>fdisk -lu /opt/qemu/tempImage</in>

Convertir de l'EPS en SVG

$ <in>pstoedit -f plot-svg fichier.eps fichier.svg</in>

Créer une vidéo à partir d'images

Les noms des images sont du type img00.jpg à 50 Hz :

$ <in>ffmpeg -f image2 -i img%02d.jpg -r 50 -vcodec mpeg4 vid.avi</in>


Two-sided printing option for landscape documents:

$ <in>lpr -o sides=two-sided-short-edge</in>


Two-sided printing

Two-sided printing with proper folding depending on the printing orientation (i.e. tumble when landscape printing), in /etc/a2ps/a2ps-site.cfg:

Printer: atp-b15-nl2-p1 | #{lp} #o #?l|-oDuplex=DuplexTumble||

or (simpler)

Options: -s2

And stapling:

Variable: lp.options | #{lp} #o #?l|"-oStaple=1Staple(Left)"|"-oStaple=1Staple(Right)"|

Forced two-sided printing

Prevent psnup (and other psutils) from cancelling two-sided printing, as per this post.

Still in /etc/a2ps/a2ps-site.cfg:

Variable: forceduplex \
        cat /etc/a2ps/duplex.ps - 
Variable: forcetumble \
        cat /etc/a2ps/tumble.ps - 
Variable: lp.hook \
        #?d! #?l|#{forcetumble}|#{forceduplex}| | !!

With PS headers duplex.ps and tumble.ps setting the right options.

PPTP-based VPN

PPPd and PPTPClient are needed for this to work

General setup

Using the PPTPClient-provided options, one can quickly create a new peer in, say, /etc/ppp/peers/pptppeer:

file /etc/ppp/options.pptp
name LOGIN
pty "/usr/sbin/pptp PPTPSERVER --nolaunchpppd"


Of course, the password needs to be added to the /etc/ppp/chap-secrets file:

# client        server  secret                  IP addresses
LOGIN           *       PASSWORD                *

Once a network connection has been established, the routes may have to be taken care of before and/or after the establishment of the :

$ <in>sudo route add PPTPSERVER DEFAULTGW</in>
$ <in>sudo pppd call pptppeer</in>
$ <in>sudo route add default gw PPTPPEERGW</in>

Where DEFAULTGW is the default route _before_ the PPTP link has been established, and PPTPPEERGW is the remote endpoint of the P-t-P connection.

Gentoo setup

First emerge the necessary package

$ <in>sudo emerge pptpclient pppd</in>

Then configure the new interface, with dependencies and needed route setup in /etc/conf.d/net:

config_ppp0=( "ppp" )
link_ppp0="pty 'pptp PPTPSERVER --nolaunchpppd'"
       "holdoff 3"
       "child-timeout 60"
       "lcp-echo-interval 15"
       "lcp-echo-failure 3"
       noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp persist
depend_ppp0() {
       depend net

preup() {
	case $1 in
			return 0

postup() {
	case $1 in
			route add default gw PPTPPEERGW dev $1
			return 0

predown() {
	case $1 in
			route del default gw PPTPPEERGW
			return 0

postdown() {
	case $1 in
			return 0

Finally, the startup link has to be created, and can be used directly:

$ <in>sudo ln -s /etc/init.d/net.lo /etc/init.d/net.ppp0</in>
$ <in>sudo /etc/init.d/net.ppp0 start</in>

ELF Files Manipulation

Get Library Dependencies without ldd

As seen here.

readelf -d ELFBIN | grep NEEDED

Cleaning Up ownCloud's conflicts

$ export MD5=md5 # BSDs
$ export MD5="md5sum --tag" # GNU
$ <in>for file in *_conflict*; do ext=${file/*.} orig="${file/_conflict*/}.${ext}"; echo -n "$file -> $orig:"; (test -e "$orig" && (test x`$MD5 "$file"|sed 's/.*= //'` = x`$MD5 "$orig"|sed 's/.*= //'` && (echo " same"; rm "./$file")  || echo " DIFFERENT")) || (echo " missing"; mv "$file" "$orig"); done</in>


Cloning/backing up a database

$ <in>mysql -u root -p CREATE BACKUPDB; mysqldump -u root -p --opt DB | mysql -u root -p BACKUPDB</in>


Get Server Version

<iq to="example.net" type="get">
  <query xmlns="jabber:iq:version"/ >
tips.txt · Dernière modification: 2015-07-28 14:14 de shtrom