Egon Rath – Blog Stuff about the things i am interested in

26Apr/12

Burn a UDF DVD in Linux (from the command line)

If you want to burn data to a DVD you can either use a GUI tool like Brasero or if you want to have more control over what get burned, use the command line. Additionally, most burning tools do not allow the usage of UDF as the Filesystem and just use ISO9660 instead. This one has a few drawbacks, for example it is not possible to add files larger than 4 GiB. Below are the steps you'll need to build a UDF Filesystem manually and burn it onto your optical media:

  1. Create a empty file with the size of the corresponding media:
    dd if=/dev/zero of=dvd_image.bin bs=1024 count=4596992

    (at the end of this blog entry you'll find a list of media sizes for different optical discs)

  2. Create the UDF Filesystem within this file:
    mkudffs -r 0x0102 dvd_image.bin
  3.  Mount the Filesystem (as root):
    mount -o loop ./dvd_image.bin /mnt 
  4. Copy data to the Filesystem
  5. Unmount the Filesystem (as root):
    umount /mnt 
  6. Burn the image to the media:
    wodim dev=/dev/sr0 -data -dao ./dvd_image.bin

Media sizes:

DVD+R SL : 4590208
DVD-R DL : 8343424
DVD+R DL : 8347648
Print This Post Print This Post
Filed under: Technology No Comments
10Apr/12

Running a VNC Server

If you want to connect to the GUI of a remote computer running Linux there is (as far as i know) no other elegant solution other than VNC.  For exactly this purpose, there is the fantastic x11vnc daemon available - with the following upstart script, it connects to the local X display as soon as it's started up:

description "VNC Server"
author      "Egon A. Rath"

start on login-session-start
stop on runlevel [016]

emits vnc-server-start

script
    x11vnc -geometry 1680x1050 -clip 1680x1050+0+0 -shared -no6 -forever -nolookup -passwd 'Test123!' -auth /var/run/lightdm/root/:0 -ncache -noxinerama -display :0
    initctl emit vnc-server-start
end script

Save the above as /etc/init/vnc.conf and logout (restarts your display server). You should now be able to connect from a remote machine using the specified password - check out the manual page for x11vnc, it's even possible to authenticate against PAM.

Print This Post Print This Post
Filed under: Technology No Comments
29Mar/12

Setting the default brightness of a LCD screen in (X)ubuntu

Quick and dirty:

Put the following line to your /etc/rc.local to set the lcd brightness via ACPI to a value between 0 and the max (later more on this):

echo 22 > /sys/class/backlight/acpi_video0/brightness

To get the maximum brightness:

cat /sys/class/backlight/acpi_video0/max_brightness
Print This Post Print This Post
Filed under: Technology No Comments
28Mar/12

Using shutter for advanced Screenshot functionality

I often need the ability to capture a part of the screen and paste it to a document. Until now, i simply used the XFCE integrated screen grabbing tool (bound to the Print Key) and cut out the are i needed in GIMP.

Because this hindered my workflow i looked for a solution which is more convenient - and found "shutter" (it's in the repositories). This little tool allows way more customization than the original screenshot utility, for example marking a rectangle on the screen and capturing just this without any further manual intervention.

Here's what i did:

  1. apt-get install shutter
  2. Disable the Keybinding for both Print Keys in the Settings
  3.  Added "shutter --min_at_startup" to launch at session startup (XFCE Session)
  4. Bound "shutter --full" to the Print Key
  5. Bound "shutter --select --exit_after_capture" to the Ctrl-Print Key combination

So, now when i press Print alone, i capture the whole screen as always, but Ctrl-Print allows me to define a rectangle on the screen and grabs it directly to the clipboard. Nice thing!

Print This Post Print This Post
Filed under: Technology No Comments
24Mar/12

KDE 4: Show Desktop and Locking the Screen

Showing the desktop:

#!/bin/sh
target=on
xprop -root _NET_SHOWING_DESKTOP | grep '= 1' 2>/dev/null 1>&2
if [ $? -eq 0 ]; then
target=off
fi
wmctrl -k ${target}

Bind this script to the Key Shortcut of your desire.

Locking the Session:

If it's not configured by your distribution, simply call

qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
Print This Post Print This Post
Filed under: Technology No Comments
20Mar/12

Dumping data from the clipboard to a File

I am currently improving my tool "equagen" to be able to copy vector graphics from it to openoffice - unfortunately that's not that easy because SVG files are inserted as text in openoffice when pasting them. For analysis i needed a quick (and dirty) way to store the content of the clipboard to a file. And this is the result - as i told you, it's just a quick hack done in a few minutes using my favorite Framework - Qt:

#include <iostream>

#include <QApplication>
#include <QClipboard>
#include <QDebug>
#include <QMimeData>
#include <QStringList>
#include <QFile>

using std::cout;
using std::cin;
using std::endl;

int main( int argc, char **argv )
{
    QApplication app( argc, argv );

    QClipboard *clipboard = QApplication::clipboard();
    const QMimeData *data = clipboard->mimeData();

    QStringList formats = data->formats();
    QStringList::iterator iter = formats.begin();
    int id = 1;

    while( iter != formats.end() )
    {
        cout << "(" << id++ << "): " << (*iter).toStdString() << endl;
        iter++;
    }

    cout << endl << "Which one to save? ";
    cin >> id;

    QFile dump( "dump.bin" );
    dump.open( QFile::WriteOnly );
    dump.write( data->data( formats.at( id-1 )));
    dump.close();

    cout << "Written to dump.bin" << endl;
}

It simply shows all the formats available in the clipboard and stores the one you select in a file. Thats it, no more to see here.

*) Kudos to everyone for using openoffice instead of libreoffice when actually meaning libreoffice - it's hard to get used to it :-)

Print This Post Print This Post
Filed under: Technology No Comments