2014-08-31 11:55

Mathilde’s contribution:

This script allows you to launch a search by filesize on opensubtitles.org, with a simple right-click on a video file.

If it does not exist, create the .local/share/nautilus/scripts directory in your personnal folder (from Nautilus, you can use the Ctrl+H shortcut to display hidden files and be able to see the .local directory).

Save the subtitle file in .local/share/nautilus/scripts

Add execution permission to the script, in file properties, or running the command chmod +x ~/.local/share/nautilus/scripts/subtitle

Open Nautilus (aka “Files”). Select the film you want to search subtitles for, right-click > scripts > subtitle.
A browser window will open directly on opensubtitles.org with your search results.

NB:
By default, the script will search subtitles in english. To change the language, open the script and change the LANG variable.

Content of subtitle script:

#!/bin/bash

LANG=eng
#LANG=fr

FILE=$1
SIZE=$(stat -c %s $FILE)

xdg-open "http://www.opensubtitles.org/eng/search/sublanguageid-$LANG/moviebytesize-$SIZE"
2014-08-31 11:55 · Tags: ,
2014-05-29 18:59

Here are the steps I used to upgrade the BIOS of my Lenovo Thinkpad X1 Carbon Gen 2.
You have to download the bootable ISO file from Lenovo support site, convert it and copy it to a usb flash drive.

You will need a USB key you can erase.

First Get the bootable ISO file from Lenovo support website. To get your product number:

sudo dmidecode -t system | grep Product

To check your BIOS version: sudo dmidecode -t bios

Get the geteltorito program from your packages or download it:

cd /tmp/
wget http://userpages.uni-koblenz.de/~krienke/ftp/noarch/geteltorito/geteltorito
chmod +x geteltorito

Extract the img from the ISO:

./geteltorito -o bios.img gruj09us.iso

Copy the img to the USB key (make sure sdb is you USB key!!):

sudo fdisk -l /dev/sdb #at least check that device size is right
sudo dd if=bios.img of=/dev/sdb

That’s it. Boot on USB stick and follow the instructions to update your BIOS.

2014-05-29 18:59 · Tags: , , , , ,
2014-04-27 14:24

If you have the problem when pushing to github for example.

You can just empty the core.askpass param:

git config --global core.askpass ''

See also man git config

2014-04-27 14:24 · Tags: , ,
2014-04-06 17:54

After searching a bit I could not find a simple and good howto to do that.
The following method should work for any Linux distribution (Ubuntu, Debian, Manjaro, Archlinux, Fedora…). Source and target systems must be on the same processor architecture (though transfer from 32bit to 64bit should work).

What you need:

  • 2 live USB keys (or cds)
  • To speed up data transfer: good quality ethernet cables (one cable between the 2 computers is OK), or a usb key/drive with a BIG ext4 partition. You can try over wifi, but it may be slow.

1. Boot source and target machines on live USB/CD

Any live USB/CD should be OK.
On the target computer, you will need a tool to partition your hard drive, like gparted.
rsync is also required for data transfer: it’s included in many live systems.

Ubuntu live cd is OK, Manjaro live cd too.

2. Partition your target hard drive

Use a tool like gparted to partition the target hard drive, with the same partitions as your source system (slash, swap, home…).
I recommend you to assign LABELs to your partitions: for the fstab, it’s easier than UUIDs.

3. Mount all partitions on both machines

On both systems, open a root terminal. Then, for each data partition (you can ignore swap):

mkdir /mnt/slash
mount /dev/sdaX /mnt/slash

If you have a home partition:

mkdir /mnt/home
mount /dev/sdaY /mnt/home

4. Transfer the data (network or usb)

This part may be tricky. Choose the method you prefer.

Network

  1. Setup the network. Test the connectivity with ping command.
    The easier is to plug the PCs on a DHCP network (like your ISP box) so that you get automatic IP addresses. If you linked the 2 pcs with a single cable, you’ll have to setup the IPs with NetworkManager (static ips, or adhoc network).
  2. On source system, as root, create a simple /etc/rsyncd.conf file:
    uid = root
    gid = root
    use chroot = no
    
    [all]
        path = /
    
  3. Then start the rsync daemon server: rsync --daemon
  4. On target PC, for each partition:
    rsync -avHX SOURCE_IP::all/mnt/slash/ /mnt/slash/
    

    Don’t forget ‘/’ at the end of paths. -a will preserve many file attributes like owner and permissions, -H will preserve hardlinks if any, -X will preserve extended attributes like setuid. You may also add -A if you are using acls. What is good with rsync is that you can stop and restart the transfer whenever you want.

USB

Prepare a USB drive with a BIG ext4 partition.

  1. Mount the USB partition on source system (mount /dev/sdbX /mnt/usb)
  2. For each partition:
    rsync -avHX /mnt/slash/ /mnt/usb/slash/
    
  3. umount, unplug and remount the USB disk on the target system.
  4. For each partition:
    rsync -avHX /mnt/usb/slash/ /mnt/slash/
    

5. Change fstab on target system

As root, edit /mnt/slash/etc/fstab
For each partition (including swap), replace the first field with the new UUID or LABEL (it’s straightforward with LABELs):
UUID=the-long-uuid, or LABEL=yourlabel

2 ways to get the UUIDs / LABELs:

ls -l /dev/disk/by-uuid/
blkid /dev/sdaX

6. Reinstall Grub

We will use a chroot (changed root environment) to be able to call the grub install inside the migrated system.

First, bind mount some system directories needed by grub, then chroot:

mount --bind /proc /mnt/slash/proc
mount --bind /sys /mnt/slash/sys
mount --bind /dev /mnt/slash/dev
mount --bind /run /mnt/slash/run
chroot /mnt/slash

Then install grub in the Master Boot Record of your hard drive, and update grub config file (with the new uuids…):

grub-install /dev/sda
update-grub

7. Reboot target machine

That’s it! Your system should be working on the new computer now.
Feel free to comment if you encounter problems.

2014-04-06 17:54 · Tags: , ,
2013-12-05 23:22

Bsync is a bidirectional file synchronization tool, using rsync for transfers. Moved files are also synchronized in a smart way.

It uses rsync for file transfers, find to generate filelist snapshots, and ssh for remote transfers.

bsync is an alternative to Unison, written in Python 3. A big strength of bsync: it can detect and apply moved files from one side to the other (Unison uses some copy calls to handle moved files).

I developped it to be able to synchronize my music directory from my laptop to my Raspberry Pi in an efficient way, and to sync with my girlfriend laptop too.

Bsync is released under GPL. Feel free to report any bugs/wishes in GitHub issues.

More info, Download and Install on the GitHub repo.

2013-12-05 23:22 · Tags: , , , , ,
2013-12-05 21:18

I just finished migrating my blog from Dotclear to WordPress.

I quickly tried some existing plugins to do the migration but none worked. My setup is a bit complicated because I was using the dc_translate plugin to translate all my posts.

Here is the migrate script. If it can be of use. Warning: you probably have to adapt the script to your needs, to remove some stuff, because it’s also reading Dotclear translation tables.

  • The script is called in command line via PHP cli
  • The script is using plain SQL to read from Dotclear database and to write to WordPress database.
  • It uses the wiki2xhtml Dotclear library to convert dotclear wiki syntax to html.
  • It uses formatting WordPress library to convert Posts url to WordPress format.
  • For each post, it also imports comments and tags.

I’m now using 3 plugins to manage my French translations in WordPress:

  • qTranslate
  • qTranslate slug
  • qTranslate Separate Comments

migrate_dc.tar

2013-12-05 21:18
2013-08-15 23:29

Thanks to:
http://vickychijwani.github.io/2012/04/15/blazing-fast-application-switching-in-linux/

I made a few improvements on the script. If you want something with more features (but also more complex).

  • Use /bin/sh so that it may use dash instead of bash (lighter)
  • Use exec to start the command so that it replaces the current script (otherwise you get unneeded bash processes in ps)
  • Raise all windows of the same class: useful to raise all terminals for example
  • “toggle mode” : when run a second time, the windows are minimized. For that I had to depend on xdotool, because wmctrl can’t do that (probably coming in a future wmctrl release. the author commited a -Y flag in github for that).

Save it to /home/USER/bin/run-or-raise, then add some keyboard shortcuts in your window manager settings and enjoy!

<Super>f /home/USER/bin/run-or-raise Navigator.Firefox firefox
#!/bin/sh
# syntax: run-or-raise WM_CLASS_name COMMAND
#   WM_CLASS_name : the WM_CALL_name of the window (from wmctrl -lx output)
#   COMMAND : the command to run if nothing to raise

#logfile=/tmp/$(basename $0).log
#exec > $logfile 2>&1

# get windows ids matching WM_CLASS_name
WINIDS=$(wmctrl -lx | awk '{ if ($3 == "'"$1"'") print $1}')

# run if nothing started. exec will end the script
[ -z "$WINIDS" ] && exec "$2"

# if the window is active, we minimize all the windows of the class
ACTIVEWIN=$(wmctrl -a :ACTIVE: -v 2>&1 | sed -n 's/^Using window: \(.*\)/\1/p')
MINIMIZE=false
if echo "$WINIDS" | grep -q "$ACTIVEWIN"; then
        MINIMIZE=true
fi

for ID in $WINIDS; do
        if $MINIMIZE; then
                xdotool windowminimize "$ID"
        else
                wmctrl -i -a "$ID"
        fi
done
2013-08-15 23:29 · Tags:
2013-07-28 18:02

To disable xfce panel and/or Thunar from starting in XFCE:

  1. Start a clean xfce session with no application started
  2. Open XFCE settings manager > Session and Startup > Session tab
  3. Set “Never” in front of xfce4-panel and Thunar
  4. Click Save Session
  5. Logout and login again to test

EDIT 2014-04-27: You can also edit /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml

To remove Thunar daemon : Remove the Client3* properties for Thunar, then replace Client4 by Client3 and update the Count property from 5 to 4.
Then restart your session.

2013-07-28 18:02 · Tags:
2013-03-16 17:41

I’ve spent days looking for a good live Multiboot USB solution. I mean a way to include many downloaded ISO files in a single USB stick. I was looking for a system allowing to drop the ISOs in a folder on the key, just showing a menu with the ISO files to boot. Easy2Boot does exactly that!

Booting an ISO file is complex because lots of live operating systems expect to be at the root of a DOS partition. After some research I found several posts saying that generic ISO chainloading is very hard (p1 p2).

I found solutions like YUMI (Your Universal Multiboot Installer (windows) or MultiSystem. At this time, the problem of those programs is that they use specific “tricks” for each distribution to build a menu that will load directly the Linux kernel. It’s not as simple as dropping your ISOs in a folder: you have to use the software to build the multiboot usb key. Another drawback is that you will loose the SYSLINUX boot menus of the distros, because it loads directly the Linux kernels.

You also have hardware usb disk drives emulating a cdrom device. It’s probably the most reliable solution, but it’s not cheap, and bigger that a small USB key.

Easy2Boot, with grub4dos scripting, uses a nice trick (described here): when the iso file is chosen from the boot menu, a DOS partition (number 4) is created starting and ending at the position of the .iso file on the FAT filesystem. This method is more “ISO generic” and can boot many ISO files (99% of Live Linuxes). The drawbacks is that you have a partition overlapping the other (this is not a problem, at least under Linux), and you have to make sure that the FAT filesystem will not fragment your ISO files when you copy them on the key.

Under Windows, you can use the RMPrepUSB software (freeware/not opensource) to prepare your USB key.

Under Linux/Ubuntu, this is simple too:

  1. Format your USB key with a single FAT partition (I recommend gparted).
  2. Download Easy2Boot (v1 Beta06 works fine) and put all the files at the root of the partition.
  3. Download grub4dos (take the last Featured version) and extract the archive on your PC (not on the usb stick)
  4. From the grub4dos folder, run sudo ./bootlace.com --time-out=0 /dev/sdX to install grub4dos MBR (make sure you use the right device!).
  5. Put some ISOs directly in the /MAINMENU directory
  6. Here you go. Reboot and enjoy!

Thanks to RMPrepUSB and to the reboot.pro forum guys!

Hints:

Links:

2013-03-16 17:41 · Tags: , , ,