2015. január 25.

Nautilus Scripts for Tablet screen rotation

After some workaround in the past, I started using nautilus scripts to rotate my Tablet display together with the stylus and eraser.
(I moved this topic now to a separate post, because the original post is outdated)

#!/bin/sh
# for Lucid Lynx to rotate the display 180 degree
xrandr -o inverted
xsetwacom set 'Serial Wacom Tablet' Rotate HALF


#!/bin/sh
# for Lucid Lynx to rotate the display 90 degree to the left
xrandr -o left
xsetwacom set 'Serial Wacom Tablet' Rotate CCW


#!/bin/sh
# for Lucid Lynx to rotate the display back to normal
xrandr -o normal
xsetwacom set 'Serial Wacom Tablet' Rotate NONE


#!/bin/sh
# for Lucid Lynx to rotate the display 90 degree to the right (to take notes)
xrandr -o right
xsetwacom set 'Serial Wacom Tablet' Rotate CW

Nautilus scripting in bash: processing multiple files / handle space in filenames

Where do I put the scripts? 

Nautilus scripts folder is in your user home directory:
in Ubuntu 12.04 and before: .gnome2/nautilus-scripts/
from Ubuntu 14.04: .local/share/nautilus/scripts/

You'll have to make all script files executable in order to be able to run them.
chmod +x

What does a nautilus script do? 

All executable files in this folder will appear in the Scripts menu. Choosing a script from the menu will run that script.

When executed from a local folder, scripts will be passed the selected file names. When executed from a remote folder (e.g. a folder showing web or ftp content), scripts will be passed no parameters.

What nautilus script specific variables can I use?

In all cases, the following environment variables will be set by Nautilus, which the scripts may use:

  • NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
    # newline-delimited paths for selected files (only if local)
  • NAUTILUS_SCRIPT_SELECTED_URIS
    # newline-delimited URIs for selected files
  • NAUTILUS_SCRIPT_CURRENT_URI
    # URI for current location
  • NAUTILUS_SCRIPT_WINDOW_GEOMETRY
    # position and size of current window
# from Ubuntu 14.04 Nautilus does not have split view (extra pane), so these variables (most likely) will not work:
  • NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS
    # newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)
  • NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_URIS
    # newline-delimited URIs for selected files in the inactive pane of a split-view window
  • NAUTILUS_SCRIPT_NEXT_PANE_CURRENT_URI
    # URI for current location in the inactive pane of a split-view window
How do these variables work? 

To test what these variables do you might use this nautilus script:
#!/bin/bash
# test your nautilus variables
touch $HOME/nautilustesting.txt
echo "SELECTED_FILE_PATHS: " "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" >> $HOME/nautilustesting.txt
echo "SELECTED_URIS: " "$NAUTILUS_SCRIPT_SELECTED_URIS"  >> $HOME/nautilustesting.txt
echo "CURRENT_URI: " "$NAUTILUS_SCRIPT_CURRENT_URI" >> $HOME/nautilustesting.txt
echo "WINDOW_GEOMETRY: " "$NAUTILUS_SCRIPT_WINDOW_GEOMETRY" >> $HOME/nautilustesting.txt
echo " " >> $HOME/nautilustesting.txt

How to use these variables?

The variables you get will look something like this (in case of selecting 4 files with spaces in the names):
SELECTED_FILE_PATHS:  /home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen inverted
/home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen left
/home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen normal
/home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen right (notes)
SELECTED_URIS:  file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20inverted
file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20left
file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20normal
file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20right%20(notes)
CURRENT_URI:  file:///home/username/.gnome2/nautilus-scripts
WINDOW_GEOMETRY:  1022x690+0+1024

How to read nautilus selected file paths with spaces into a bash array?

To have a use of them as input file path for example imagemagick, I'll have to deal with the spaces, because these command line programs usually take "file path" as input and do not take "file URI" as input, and file path may contain spaces.

The FAQ of the G-Scripts site suggests some ways to handle this:
  1. protect your variable with double quotes: instead of $1 use "$1"
  2. process the filenames with SED:
    files=`echo "$1" | sed 's/ /\\ /g'`
  3. process the filenames with AWK and SED:
    quoted=$(echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | awk 'BEGIN {FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##); eval "your-program $quoted"
Actually, for me NONE of the above worked.
I found my solution in a stackoverflow post. It uses the IFS value to deal with the filenames. I read somewhere that using the IFS is an inelegant way to deal with field separators, and one should use AWK FS variable instead.

My solution: 

This is to use with nautilus scripts:
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS
This is to use with my image manipulation scripts (where the script file is located in the same folder as the to-b-manipulated files):
IFS=$'\n' read -d "" -r -a filelist < <(find -iname "*.jpg" | sort); unset $IFS
When you want to call the elements of the array, you'll have to put them in double quotes, like
for i in "${filelist[@]}" 
do echo "$i"
done
Google search keywords to find the solution:

  • escape space in bash script
  • awk fs line break
  • sed change space to newline
  • escape space in bash script with sed
  • internal field separator
  • bash read file names into array
  • bash read space file names into array
  • echo into array bash
  • while read output array bash


2015. január 22.

How to format HTML tables in Blogger to fit the available space

I sometimes have to use tables in my posts, and it always causes me trouble to format them properly to fit the available width of my blog. So I decided to post a note about the formatting I use.
This is kind of a repost of this post.

Here you can read about the general usage of tables. Please do so.

If I have to shrink a table width to fit inside the blog width I use this setting in the <table> tag:
<table border="1" cellspacing="0" style="table-layout: fixed; width: 100%;" >

If I have to stretch the table width I simply use this setting in the <table> tag:
<table  style="width: 100%;" >

A selection of Lightweight Ubuntu alternatives

I was considering to leave Ubuntu, and therefor I searched for alternatives.
These are the ones I found worthy of trying out in the first round:


CrunchBang Linux Lubuntu wattOS LXLE Bodhi Linux
OS Type: Linux Linux Linux Linux Linux
Based on: Debian (Stable) Debian, Ubuntu Debian, Ubuntu Debian, Lubuntu Debian, Ubuntu
Origin: United Kingdom France, Taiwan USA USA USA
Architecture: i486, i686, x86_64 armhf, i386, powerpc, x86_64 i386, x86_64 i386, x86_64 armhf, i386, x86_64
Desktop Manager: Openbox LXDE, Openbox LXDE, MATE, Openbox LXDE Enlightenment
Windows Manager: Openbox? Openbox Openbox Openbox? Enlightenment
File Manager: Thunar File Manager PCManFM PCManFM PCManFM EFM
Category: Desktop, Netbooks, Old Computers Live Medium, Netbooks, Old Computers Desktop, Live Medium, Netbooks, Old Computers Desktop, Live Medium, Old Computers Desktop, Live Medium, Old Computers, Raspberry Pi
Status: Active Active Active Active Active
Popularity: 22 (478 hits per day) 15 (723 hits per day) 58 (249 hits per day) 11 (770 hits per day) 20 (548 hits per day)
Official page: http://crunchbang.org/ http://lubuntu.net/ http://www.planetwatt.com/ http://lxle.net

What I need from my OS, is written in a previous post. I'll use this as a checklist when trying out the new distributions.

2015. január 19.

Some trouble I experience with Ubuntu 12.04 and Gnome Classic w/o effects


  • nautilus crash on removing external drives
  • window shadows are partially left behind after the window was moved or closed
  • after awaken from suspended mode, pressing the ctrl key caused a change in the display settings on a dual monitor setup. Each time the ctrl key was pressed the display setting changed between 1. extended displays 2. mirrored displays 3. one display turned off.
  • in Firefox, Google applications tend to freeze for like 20 seconds and don't register clicks

2015. január 18.

Gnome Classic tweaks on Ubuntu 12.04.5 Precise Pangolin compared to 14.04.1 Trusty Thar

In this post I'm going to configure Ubuntu 12.04.5. LTS to my taste. Since I configured a 14.04.1 LTS just a couple of weeks ago the exact same way, I will compare the how-to of these settings.

What do I need from Ubuntu?
- this post has the list of features I'm going to test against Precise Pangolin.

Desktop Environment Choices
- I chose Gnome Flashback Services again, but in 12.04 it is called Gnome Classic (with or without effects) and can be installed by installing the package gnome-session-fallback instead of gnome-session-flashback.
- Synaptic package manager is not installed by default on 12.04, just like on 14.04, so it has to be installed from terminal with the sudo apt-get install synaptic command (or probably from Ubuntu Software Center, which I prefer to not use)

All the following notes are based on using Gnome Classic without Effects.

Setting up everything

Gnome Classic is somewhat different from Gnome Session Flashback.
Some useful tips can be found in this ubuntu forum thread.

Otherwise, compared to Ubuntu 14.04:
  • HP Compaq TC4400 native features:
    • pen features: the same
    • screen rotation: the same
    • on-screen buttons: the same
  • Terminal: the same
  • Workspaces: the same
  • Panels: the same
  • Synaptic: the same
  • File manager: Nautilus still can do all I want, so I'll stick with it.
    • Scripts: the same
    • Open in Terminal: the same (install nautilus-open-terminal package to get right click option "Open Terminal") 
Tablet input usage in multi-screen environment compared to Ubuntu 10.04 Lucid Lynx:
  • xinput has a new version, and it enables to map the tablet input device to the tablet screen by using xinput --map-to-crtc device crtc
    • where device is the device ID of the stylus or the eraser taken from xinput --list
    • and the crtc is the name of the tablet monitor taken from xrandr
    Changing the Date and Time format in the indicator applet
    - on Precise there is no configuration editor pre-installed.
    - DConf Editor can be installed by installing dconf-tools - then it will be available as dconf-editor of from the Applications menu > System Tools > DConf Editor
    - after installing it, setting custom date and time format can be done as in Trusty, described in the post linked above.

    Indicator Applet
    - Gnome Classic installs indicator-applet-complete, but there are more then one indicator applet that can be downloaded with synaptic. The difference between them is this:
    • indicator-applet-complete is: messaging applications, power settings, bluetooth settings, network settings, sound settings, date and time settings, user accounts, session management
    • indicator-applet is: messaging applications, power settings, bluetooth settings, network settings, sound settings
    • indicator-applet-session is: user accounts, session management
    • indicator-applet-appmenu is: your active application's menu header
    Some modifications can be made to the features shown in the indicator applet with DConf editor - as described above. 

    Remove messaging envelope from indicator applet
    This AskUbuntu post holds the solution: to remove just the envelope icon from the indicator applet indicator-messages package has to be removed with sudo apt-get remove indicator-messages and then gnome-panel restarted with sudo pkill gnome-panel

    Running Java Applets on websites
    - icedtea-7-plugin solves this on Ubuntu 12.04.5, just like it does on 14.04.1.

    Reserving space for the top panel between monitors
    the same, except for the panel height. It is still 24 pixels, but when set with _NET_WM_STRUT_PARTIAL 1024,0,0,0,1024,1048,0,0,0,0,0,0 a single pixel space remains under it, so it has to be set with _NET_WM_STRUT_PARTIAL 1024,0,0,0,1024,1047,0,0,0,0,0,0

    Enable Compositing for Gnome Classic without effects
    In Trusty Thar Metacity Compositing can be enabled by opening dconf-editor and navigating to > org > gnome > metacity > compositing-manager > mark checked.
    In Precise Pangolin there is no such option in dconf-editor. Instead you'll have to install gconf-editor and set it there. Once installed, you can find it in the Applications menu > System Tools > Configuration Editor. Inside it navigate to apps > metacity > general and set a checkmark next to "compositing_manager"
    This will enable real window transparency (i.e. terminal window), window shadow, Alt+Tab window selector shows screenshot of the window; and it is said to support AWN, and Gnome Do, but I did not try these.

    Aero Snap for Gnome Classic (no effects)
    the same, except for the key combinations: in Ubuntu 12.04 instead of Mod4 + Super_L + Left combination it is only Mod4 + Left

    Repository download checklist:
    • synaptic
    • gnome-session-fallback
    • nautilus-open-terminal
    • wmctrl
    • xbindkeys
    • dconf-tools
    • gconf-editor
    • gimp (GUI image manipulation tool)
    • inkscape (GUI vector-based drawing program)
    • imagemagick (convert, mogrify, identify)
    • pdftk
    • pdfjam (pdfjoin)
    • djvulibre-bin (ddjvu, djvused, cjb2, djvm, c44)
    • potrace (mkbitmap)
    • unpaper
    • keepass2
    • keepassX
    • nautilus-dropbox (Dropbox) fails to complete installation.
    Web download checklist:
    to install deb packages run sudo dpkg --install [packagename.deb]
    to install packages with dependencies, install gdebi first from synaptic, then run sudo gdebi [packagename.deb] - gdebi is like Ubuntu Software Center ("USC") in the Command Line Interface ("CLI")
    • Dropbox: does not show system tray indicator in notification area (see description below)
    • Skype: looks all right.
    • Rescuetime: looks all right.
    • Plex Media Server: looks all right.
    • Google Chrome: looks all right.
    Dropbox installation troubles:
    - when installing nautilus-dropbox the process failed to move forward after downloading 100% of the dropbox installer. After killing this process somehow, I could not install anything, but got the message: "E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem." So I did as was asked, and then nautilus-dropbox configuration continued with downloading the installer and stopping after 100% again. I could get out of this infinite loop by following the instructions in this post. I edited the /var/lib/dpkg/info/nautilus-dropbox.postinst file and inserted a "exit 0" line as the second line right after the "#!" line. Then dpkg could finish the process by quitting without really configuring dropbox, so after this I removed the whole thing with sudo apt-get remove nautilus-dropbox and intalled the deb package downloaded from dropbox site.
    - the deb package installed all right, but the dropbox tray icon is missing from the notification area. I searched for a solution, and some places suggest removing dropbox and installing nautilus-dropbox instead, but this obviously will not work for me. Another post is suggesting more ways to get the icon working, and I tried all of it (notification area, unity-panel whitelist, autostart y), but none of them worked.
    - I added the dropbox gpg key to the repositiry, did an apt-get update, and than tried to install nautilus-dropbox, but got the message: "Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies:  nautilus-dropbox : Depends: dropbox but it is not going to be installed E: Unable to correct problems, you have held broken packages." So I searched, and found, and did an apt-get upgrade, which upgraded dropbox only, because this was the broken package, and then after restarting dropbox, nautilus and gnome-panel, there was this 1x1 pixel white dot in the notification area, which on mouse-over shows a label "Dropbox 3.0.5 Up to date" and can be right-clicked to reach dropbox menu. Nautilus-dropbox is still not installed as a package.
    - when I copied the dropbox icons to the icon fallback directory, the dropbox icon showed up on the panel.
    Dropbox icons are stored in the /home/[user]/.dropbox-dist/dropbox-[version]/images/hicolor/16x16/status/
    Icon fallback directory for them is /usr/share/icons/hicolor/16x16/status/
    However, after restarting the panel it was only the 1x1 pixel dot again, and restarting dropbox didn't help. Icons are still there in the fallback directory.
    A note: Skype puts it's icon next to the Dropbox pixel, and it works perfectly, so the problem is definitely with Dropbox.

    2015. január 17.

    Migrating from Ubuntu 14.04.1 LTS to 12.04.5 LTS

    I decided to abandon Ubuntu Trusty Thar LST after about two weeks of usage. I was pretty upset about it. This is what I wrote when I made the decision:
    I actually have to do paid work on my laptop, so it needs to be as reliable and as fast as possible.
    Ubuntu Trusty with gnome session flashback was great. Really. The only little tiny problem was that it lasted only until I had to really depend on it because of my job. My job, that is 99% spreadsheet and internet browser work. Opening 10-20 chrome windows during a single search process takes all the memory, and freezes the system. Firefox is not really that better than chrome in memory usage. And Libreoffice... the spreadsheet I work with is like 2000 rows by 40 columns data and another 6 sheets of database queries made with functions. Libreoffice just could not handle this. It was terribly slow, lagging when scrolling, saving took up to a minute, and all 4.x versions crashed regularly.
    No, this is not something anyone would recommend to do your job on. Not in 2015.
     I was planning to abandon Ubuntu at all, and choose a lightweight alternative, probably one that is based on Ubuntu. Then I realized Ubuntu Precise Pangolin is supported up to 2017, so I thought I'll give it a try before completely saying good-bye to Ubuntu.

    I set up a similar environment as on Trusty. In Precise, it is gnome-session-fallback that gives back the Gnome2 environment. It can be downloaded from Synaptic Package Manager, which can be downloaded with the sudo apt-get install synaptic command in the Terminal, which can be opened with the Ctrl+Alt+T command.

    2015. január 12.

    Some trouble I experience with Ubuntu 14.04 and Gnome-session-flashback

    • nemo crashed
    • xprop -set _net_wm_strut_partial gets overwritten frequently
    • login screen changed after running out of battery in suspended state
    • libreoffice (4.2.7) calc and writer failure: when setting font color, gnome-panel turns invisible, (but still works, when I click to the places where the buttons should be, they function well) and right-click menus inside libreoffice disappear.
      (can be restored with sudo pkill gnome-panel, but is frequent (more times a day) and annoying.)
    • libreoffice (4.2.7) is extremely slow: it's lagging!
    • libreoffice (4.2.7) calc formatting is incorrectly shown. Cells with the same formatting appear differently: fonts mismatch in size and style (serif/sans-serif)
    • libreoffice (4.2.7) calc graphical interface elements are incorrectly shown. checkboxes sometimes have checkmarks, sometimes don't.
    I upgraded to LibreOffice 4.3.3 using this method.

    2015. január 11.

    Aero Snap for extended display on different screen resolutions - a workaround

    In this AskUbuntu post, a solution is described to have the Aero snap to left and right in Metacity Ubuntu. I covered the content of the post previously based on the post, and added a snap up and snap down function too.

    This AskUbuntu post, from the same user, is aiming to develop the solution further for multiple monitors. Based on this post I'll do my own workaround.

    I have two displays. One is 1024x768, the other is 1280x1024 in resolution.
    I either put them beside or on top of each other.
    I already worked out the usage of the tablet screen as a tablet in similar settings.

    I will call displays beside each other "Sided", and displays on top of each other "Topped".

    Sided screen is 2304x1024, Topped is 1280x1792 in resolution.

    The script as is, puts the active window according to this table:
    SnapSided displayTopped display
    leftleft screenbigger screen left
    rightright screenbigger screen right
    upbigger screen upupper screen
    downbigger screen downlower screen

    There are problems with the resized window's sizes, caused by the different screen sizes and the expanded edge panels (top and bottom panel). This is what I would like to fix.

    Defining screens
    the tool for dynamic screen manipulation is xrandr.

    Normal/Default (with only one screen and the expanded edge panels (top+bottom) in place)
    Small display maximized window is 1024x692 in position 0:80
    Big display maximized window is 1280x948 in position 0:80


    Topped Displays
    Small display (with panels) maximized window is 1024x716 in position 0:1080
    Small display maximized window is 1024x740 in position 0:1080
    Big display (with panels) maximized window is 1280x972 in position 0:80
    Big display maximized window is 1280x996 in position 0:56

    As is visible from the altering numbers, either the top or the bottom of the windows are hidden under the edge panels in the Topped view.
    This is a problem experienced by different users in AskUbuntu and elsewhere.
    It is caused because "panels in between monitors are not supported, and this is a limitation in the freedesktop specification for reserving space for things like panels."

    # What is my Desktop Manager? ("dm")
    ~$ env | grep XDG_CURRENT_DESKTOP
    Mine is GNOME.

    # What is my Window Manager? ("wm")
    ~$ wmctrl -m
    Mine is Metacity. It's configuration tool is gconftool-2.
    It can be set to be a compositing window manager (like compiz but simpler) by opening dconf-editor and navigating to > org > gnome > metacity > compositing-manager > mark checked. It has these features: real window transparency (i.e. terminal window), window shadow, Alt+Tab window selector shows screenshot of the window; it is said to support AWN, and Gnome Do.


    #What is EWMH?
    EWMH is a standard for window management. For more info visit this site.

    # What is the full size of the display?
    that is given by ~$ wmctrl -G -l | grep Desktop
    or by ~$ xwininfo -root | grep Height and ~$ xwininfo -root | grep Width
    or by ~$ xwininfo -root | egrep '(Height|Depth)' displayed in two rows.

    # Is the view topped or sided?
    if width>height it is the sided view, else it is the topped view.

    # What are the single display sizes?
    they are given by xrandr -q | grep '*' displayed in two rows.

    #What are the names of the displays?
    they are given in ~$ xrandr -q
    my displays are LVDS1 and VGA1 indicating the connection port they use.

    # How many displays do I have?
    ~$ xrandr -q | grep -c -w connected

    # What are the positions (coordinates) of the displays?
    they are given in ~$ xrandr -q in the form of XxY+W+H where the W and H are the x and y positions

    # Which display has the edge panels?
    the primary display has them. that is given by ~$ xrandr -q | grep -w primary

    #What do I need?
    • I need the edge panes handled so they would not hide any portion of the maximized windows. --> partially done.
    • I need new scripts for moving a windows to either one of the displays.
    • I need the snap-to-sides scripts to work within the screen where the window actually is.
    • A next step would be if this whole thing would work by dragging the windows to the side of the screen, like on Microsoft Windows.
    #References
    #Tools (manpages)

    How to reserve space for panel between monitors

    I have two monitors set up above each other.
    The primary monitor is the lower one, and has the two edge panels on the top and bottom of the display.
    The setting looks something like this:
    +---------------+
    |               |
    |               |
    |               |
    |               |
    |-----------+---+
    |'''''''''''|
    |           |
    |,,,,,,,,,,,|
    +-----------+
    However, when I maximize a window on the screen with the panels, the panel between the two screens gets ignored, and the window maximizes partially behind it, hiding the top of the window (where the controls are). The same thing happens with the bottom panel, if I switch the panels to the upper monitor.

    I ran into this problem while trying to configure a snap-to script for a two monitor environment. Obviously, I had to sort this out before moving forward with the script.

    The heart of the problem is the thing called "strut" which is basically a reserved space on the screen for a window.

    Long story short, a strut for a window can be set with xprop.

    You can find more information about the things I describe below on the xprop manpage, the ewmh reference page, and on the manpages of xwininfo, xrandr and grep.

    Let's get started!

    First you'll need some information about your screen setup to know what you're doing is right.

    Get the size of your virtual screen (you can skip this):
    xprop -root | egrep '^(_NET_WORKAREA)'


    I got this (I have 4 workspaces, this is why the numbers appear four times in a row):
    _NET_WORKAREA(CARDINAL) = 0, 0, 1280, 1792, 0, 0, 1280, 1792, 0, 0, 1280, 1792, 0, 0, 1280, 1792
    So my screen is 1280x1792 pixels, and it's one big virtual screen alltogether.
    I know that my upper screen is 1280x1024 in resolution, and the lower one is 1024x768. If I needed to check this with a command, I would use xrandr -q | grep '*'

    Get the ID of the relevant panel (you'll have to click on the panel after you run this):
    xwininfo | grep -w id


    I got this:
    xwininfo: Window id: 0x1600007 "Top Expanded Edge Panel"
    Now I know the ID of the top panel is 0x1600007. I'll need this later.

    Get an idea about the strut currently set for your panels (you can skip this):

    xprop -id 0x1600007 | egrep '^(_NET_WM_STRUT_PARTIAL)'


    I got this:
    _NET_WM_STRUT_PARTIAL(CARDINAL) = 0, 0, 0, 0, 0, 0, 0, 0, 0, 1023, 0, 0

    For a comparison, this is the same output for the bottom panel - notice the "24" in the fourth place:
    _NET_WM_STRUT_PARTIAL(CARDINAL) = 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 1023

    Now, plan your setting!
    How to use ewmh _net_wm_strut_partial property?

    The property you want to set is somewhat complicated. The lot of zeros and non-zeros you see above mean the following:
    _NET_WM_STRUT_PARTIAL, left, right, top, bottom, left_start_y, left_end_y, right_start_y, right_end_y, top_start_x, top_end_x, bottom_start_x, bottom_end_x,CARDINAL[12]/32

    This is still very confusig. I could sort out these settings for myself thanks to this stackoverflow post.

    The values are not independent of each other: they are groups. They have to be used together like this:
    left & left_start_y & left_end_y
    right & right_start_y & right_end_y
    top & top_start_x & top_end_x
    bottom & bottom_start_x & bottom_end_x
    The trick is that you use only one group of values for one window setting. Choosing the one depends on the position you want the window to take.

    I will show how to do this on my settings.
    My screen dimensions are 1280x1792. The upper screen is 1280x1024, the lower is 1024x768 big.
    If I want to reserve space on the bottom of this area, I will relate to this area with the "bottom" value group. So for a panel 1024x24 big, I'll use bottom = 24, bottom_start_x = 0, bottom_end_x = 1024. (because this is on my smaller screen).
    Likewise, if I want to reserve space on the top of the two screen big area, I will relate to this area with the "top" value group. So for a panel 1024x24 big, I'll use top = 24, top_start_x = 0, top_end_x = 1280. (because this is on my bigger screen).
    However, if I want to put the panel to the top of the lower, smaller screen, I will have to relate to the "left" group, because the left screen sides are the ones lined together (creating a dead area besides the right side of the lower screen).
    Relating to the "left" group looks like this: left = 1024 (this is the width of my panel),  left_start_y = 1024 (this is the height of the upper screen), left_end_y= 1048 (this is left_start_y plus the height of my panel (24)).
    Reserving space on the upper screen for the bottom panel could be done with the "left" group, but I will demonstrate it with the "right" group. It will be: right = 1280 (with of panel), right_start_y = 1000 (which is the height of the upper screen minus the height of the panel (24)), right_end_y = 1024 (height of upper screen).

    Generally, you define left, right, top and bottom relative to the left, right, top and bottom edge of the whole virtual screen, and you define the rest of the values in the regular coordinate system, the top left corner of the whole screen being x=0, y=0, and the bottom right corner being x= full width, y= full height.

    Now I have all the values I want to set, and all the information to set them.

    I will use xprop -set to set them.
    xprop -id 0x1600007 -f _NET_WM_STRUT_PARTIAL 32c -set _NET_WM_STRUT_PARTIAL 1024,0,0,0,1024,1048,0,0,0,0,0,0


    The meaning of options are:

    -id 0x1600007 (this is the window ID I got from xwininfo)
    -f _NET_WM_STRUT_PARTIAL 32c (this is the format of the property I am about to set. for more info check out the manpage)
    -set _NET_WM_STRUT_PARTIAL 1024,0,0,0,1024,1048,0,0,0,0,0,0 (this is the property and the values I am setting)

    A future plan is to make the system automatically set this option for any kind of multi-monitor setup.

    UPDATE: 
    I wrote a script to calculate the position of the floating panel and set the strut for me (still manually):

    2015. január 10.

    Aero snap for Ubuntu 14.04 Flashback with Metacity

    In this AskUbuntu post, a solution is described to have the Aero snap to left and right in Metacity Ubuntu. This AskUbuntu post, from the same user, is aiming to develop the solution further. I'll just cover the info from the first post here:

    EDIT: I changed the code a little bit to fit my screen better.

    You'll need to install two packages for this thing to work:
    sudo apt-get install wmctrl xbindkeys

    Than you'll need to create two scripts: one for snap left and one for snap right:
    Create the files in terminal and give them right to execute by:
    sudo touch /bin/snapleft.sh
    sudo chmod ugoa+rx /bin/snapleft.sh
    sudo touch /bin/snapright.sh
    sudo chmod ugoa+rx /bin/snapright.sh 

    Open the snapleft.sh by
    sudo gedit /bin/snapleft.sh
    

    Copy this text into it:
    #!/bin/bash
    sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,0,`xwininfo -root | grep Width | awk '{ print (($2/2)-2)}'`,`xwininfo -root | grep Height | awk '{ print $2 }'`

    than save and close it.
    Open the snapright.sh by
    sudo gedit /bin/snapright.sh
    

    Copy this text into it:
    #!/bin/bash
    sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,`xwininfo -root | grep Width | awk '{ print (($2/2))}'`,0,`xwininfo -root | grep Width | awk '{ print (($2/2))}'`,`xwininfo -root | grep Height | awk '{ print $2 }'`
    than save and close it.

    Now set the keyboard shortcuts with xbinkeys (to the left-side "super"/windows key and the left and right arrow keys) by
    printf '"bash /bin/snapleft.sh"\n Mod4 + Super_L + Left\n' > ~/.xbindkeysrc 
    printf '"bash /bin/snapright.sh"\n Mod4 + Super_L + Right\n' >> ~/.xbindkeysrc

    You can check the name of a key (if something is amiss) with
    xbindkeys -k


    NEW STUFF:

    To have a snap up and snap down function use the above guide with the following changes:

    script name: snapup.sh
    script content:
    #!/bin/bash
    sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,0,`xwininfo -root | grep Width | awk '{ print $2 }'`,`xwininfo -root | grep Height | awk '{ print (($2/2)-40)}'`
    binding key: Mod4 + Super_L + Up

    script name: snapdown.sh
    script content:
    #!/bin/bash
    sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,`xwininfo -root | grep Height | awk '{ print (($2/2))}'`,`xwininfo -root | grep Width | awk '{ print $2 }'`,`xwininfo -root | grep Height | awk '{ print (($2/2)-40)}'`
    binding key: Mod4 + Super_L + Down

    Login screen - restore to default from ugly gray version

    After my laptop shut down from suspended mode due to empty battery I experienced upon next login an ugly gray login-screen (fully functional) instead of the beautiful default unity login screen.

    In trying to restore the default login screen, I learned that LightDM is responsible for running the display manager which starts the X servers, user sessions and greeter (which is the login screen). The one I'm missing is the Unity Greeter, which is default in Ubuntu 14.04.

    Some forums suggested to reconfigure LightDM with
    ~$ sudo dpkg-reconfigure lightdm

    and set lightdm to be the default DM.
    I did this and did a logout, but it changed nothing.
    Then I logged in again, and tried out the following (user configure LightDM), but then I rebooted the machine, and the the unity login screen was back, and then I reversed the changes I made in the LightDM myconfig, and rebooted again, and the unity login screen was still there, so apparently the LightDM reconfigure solved the problem for me.

    As I learned from LightDM Ubuntu Wiki page, LightDM configuration can be overridden with user configuration.

    To open the example file showing all the possible configuration:
    ~$ gedit /usr/share/doc/lightdm/lightdm.conf.gz


    To create the user conf file:
    ~$ sudo mkdir /etc/lightdm/lightdm.conf.d
    
    ~$ sudo touch /etc/lightdm/lightdm.conf.d/50-myconfig.conf


    To edit the user conf file:
    ~$ sudo gedit /etc/lightdm/lightdm.conf.d/50-myconfig.conf


    I just copied the example file content in gedit my config file and edited the relevant section.
    To edit the greeter, you'll have to edit the "greeter-session" in "[SeatDefaults]" section.

    in [SeatDefaults] section, there is a line
    #greeter-session=example-gtk-gnome


    uncomment this line by removing the #, and change "example-gtk-gnome" to one of the greeters available to you.
    You can check available greeters by
    ~$ ls /usr/share/xgreeters/

    greeters have an extension .desktop, their name is the one before the extension.
    To use unity-greeter, you'll need the line
    greeter-session=unity-greeter

    to be in your user config file.

    Restart your computer to try it out, if logging out does not show any changes.

    2015. január 9.

    How to change the date/time format

    To customize the format of time and date displayed on the top panel indicator, and set a different format than any other locale format, you'll have to edit manually from dconf Editor.

    Open dconf Editor:
    ~$ dconf-editor

    Navigate to com > canonical > indicator > datetime

    1. Set "time-format" to "custom"
    2. Set "custom-time-format" to the format you want.
    3. Make sure that "show-clock" is check-marked.

    To check out available formatting options, see the manpage of strftime.
    ~$ man strftime

    My setting is %Y-%m-%d %H:%M:%S
    Which looks like this: 2015-01-09 09:04:51

    My other favorite setting is %Y.%m.%d. %a. %H:%M:%S
    Which looks like this: 2015.07.02. cs. 09:04:51 (where cs. is the local abbreviation of Thursday)

    With the custom date-time format you can still use the options for the calendar (show-calendar, etc.), but the options for the clock will make no change on the displayed custom time-date format.

    2015. január 8.

    Java Applets on Trusty Thar (14.04)

    I had trouble with my net-bank in Lucid Lynx, which problem was solved by installing the sun-java6-plugin.
    (this is the ominous page)

    Now, after switching to Trusty Thar, my net-banking site still does not work out of the box, because java does not come preinstalled with Ubuntu, so I have to try and find the best option for myself again.

    Luckily this time it was enough to install icedtea-7-plugin through synaptic, and the Java Applet of my net-bank works smoothly.



    Gnome Flashback Services personalization on Ubuntu 14.04 LTS

     Here are the settings and adjustments I made on Gnome Flashback Services (with Metacity) to meet my needs:

    Setting up HP Compaq TC4400's native features

    Pen features
    • Pen, eraser and button are recognized out of the box.
    • Pressure sensitivity has to be set specifically for the software you use.
    • Gimp setup for pen usage (pressure sensitivity and differentiation between the pen and the eraser:
      Gimp > Edit > Input devices > Serial Wacom Tablet eraser/stylus > set Mode "screen"
    Screen rotation
    On-screen buttons
    • Ctrl-alt-del button is recognized out of the box.
    •  Jog dial for scrolling: the code in my previously published solution works fine.
    • Pen activated buttons: not working. Linked solution have not been tested.
    • Fingerprint Sensor: not working. No possible solution have been tested.
    • Ambient Light Sensor: not working. No possible solution have been tested.

    Setting up everything else

    Terminal:

    Terminal usage
    • works as usual. 
    • keyboard shortcut (native) to open: Ctrl+Alt+T
    Bash scripts


    Desktop:
     
     Workspaces:
    • works as usual (although only in Metacity version of Gnome2 Flashback)
    • to configure: right click on the workspaces icon in the bottom right corner of the screen > Preferences
    • keyboard shortcut (native) to navigate between workspaces: Ctrl+Alt + arrow keys
    Menu panel (top and bottom) customization:
    • works as usual (except for how to reach the right click menu)
    • Alt+ right click to reach the panel menu


    Synaptic Package Manager
    • install from Software Center
    • works as usual


    File manager 

    Nautilus
    Nautilus went through major changes since Lucid Lynx, so let's see what remains of it:
    • Nautilus was renamed to "Files"
    • Compact View --> removed
    • File or folder selection by simply typing --> still exists
    • New Document > Empty Document --> still exists
    • Menu bar --> removed.
    • Menu button --> added. It's a gear wheel icon in the top right corner
    • ‘Go’ menu --> removed
    • Enter Location... --> added
    • F3 split screen --> removed (this is most annoying!)
    • Tabs --> still exists.
    • ‘tree’ view --> not default for List view, but you can set it in Preferences
    • Bookmark menu --> still exists. Only shown if there are items in it. 
    • Locations' default bookmarks --> added. Cannot be removed and icon cannot be changed, but name and location can be edited.
    • Backspace shortcut to return to parent folder --> still exists.
    Nautilus scripts
    • Scripts folder was moved from /home/user/.gnome2/nautilus-scripts to /home/user/.local/share/nautilus/scripts
    • Right clicking to reach Scripts menu only works when you click on a file or folder.
    • Otherwise works as usual.
    • A graphical user interface to manage nautilus scripts now exists.
     Nemo
     Nemo is an alternative to "Files" (Nautilus).

    • can be installed from Software Center ("Files (nemo)")
    • works just like the good old Nautilus, with F3 dual pane and every other feature.
    Nemo scripts
    • works just like Nautilus scripts.
    • scripts folder is /home/user/.gnome2/nemo-scripts
    I chose Nemo as my default Ubuntu 14.04 File manager.
    To set Nemo to be the default file manager, you have to follow these steps:
    1. To make Nemo the default file manager run in terminal:
      xdg-mime default nemo.desktop inode/directory application/x-gnome-saved-search
    2. To make Nemo handle the desktop run in terminal:
      gsettings set org.gnome.desktop.background show-desktop-icons false
      gsettings set org.nemo.desktop show-desktop-icons true
      
    3. (Optionally) To remove desktop shortcuts created by Nemo run in terminal:
      gsettings set org.nemo.desktop home-icon-visible false; gsettings set org.nemo.desktop trash-icon-visible false; gsettings set org.nemo.desktop computer-icon-visible false; gsettings set org.nemo.desktop volumes-visible false
      
    More information on Nemo can be found here and here.

    Ubuntu 14.04 LTS (64-bit) Trusty Thar personalization

    Your options for a Desktop Environment are:
    • Unity (Ubuntu default)
    • Gnome (3) (install from Software Center)
    • Gnome (2) Flashback Services (install from Software Center) - use it with Metacity
    You can install all of this and select the one you want to use at login by clicking on the circle icon in the up-right corner of the user selection.
    There are several posts helping to make your decision:
    My decision is: Gnome (2) Flashback Services with Metacity.

    Migrating from Ubuntu 10.04 LTS Lucid Lynx to 14.04 LTS Trusty Thar on HP Compaq TC4400 Tablet PC

    For these 4 years I sticked with Lucid Lynx despite the lessening support and the increasing complications and deficiencies, because of the beloved Gnome2 interface and all the customization I made throughout the years I used it.
    However, Lucid Lynx is not supported anymore, and the difficulties this bare fact caused me recently reached my limits.

    I backed up all my data and profile files to an external hard drive, and erased the whole hard disk to start anew.

    I gave Ubuntu 20GB space for the system, 5GB for swap space, and put /home to a separate partition.
    I installed the 64-bit version (finally, after 7 years of using the 32-bit version on my intel dual-core cpu because the first ubuntu distro I set on it still did not cover my needs on 64-bit) of Trusty Thar.

    Now what's next is the personalization.
    Will I stick with Gnome2, or will I migrate to Gnome3 or Unity?

    What do I need from Ubuntu?

    • it should work with the HP Compaq TC4400's native features.
      • Pen features: pen, eraser, pen-button, pressure-sensitivity
      • Screen rotation for pen usage
      • Screen mapping for multi-screen setup
      • Display side located buttons (scroll jog dial, ctrl-alt-del)
      • Pen activated buttons on the side of the display (have never worked with Ubuntu previously)
      • Fingerprint Sensor on the side of the display (I never tested it in Ubuntu previously)
      • Ambient Light Sensor (I never tested it in Ubuntu previously)
    • it should support the functionality of nautilus scripts and bash scripts
    • it should allow full control over the system from terminal
    • it should support easy access of software, applications, files and folders, without having to remember any name at all, so basically it should support easy, icon-based and menu-based navigation, where the user only has to remember visually and motorically to be able to locate anything. (menus to navigate through with keyboard or mouse)
    • it should constantly give feedback about system performance (System Monitor in top panel)
    • it should have a file manager (nautilus) that makes copying and moving files easy (2 panel view F3), have favorite places stored to reach them easily (bookmarks), have compact view with small icons that allow a lot to be seen at once (compact view). It is also great to have tree view, to make file moving/copying even easier.
    • it should have multiple desktop workspaces available
    • it should allow switching between running software by clicking with mouse
    • it should have a software center that allows switching between software versions (synaptic)
    • it should be light on my hardware
      • it should support working intensively with large xlsx, xls and ods files with a lot of cells being functions.
      • it should support opening a lot of web browser windows simultaneously
    • it should work with these specific software: 
      • Dropbox
      • Skype
      • Rescuetime and Toggl
      • keepass2 and keepassX
      • Plex Media Server
      • imagemagick, pdftk, mkbitmap, scanimage and other command line image manipulating tools I'm used to work with

    Installing Windows and Ubuntu to DualBoot

    Read the Ubuntu Help Wiki on WindowsDualBoot

    Generally:

    1. Backup your hard drive. All of it.
    2. Have a Windows installer and an Ubuntu installer ready.
    3. Install Windows first, than Ubuntu second.
    ---------------
    Additional notes to Windows7 installation:
    • to be able to change the display language you'll need Win7 Ultimate or Win7 Enterprise.
    • download additional language packs from the Control Panel, or directly from this site.
    • I gave 40GB space for Windows7 on my hard drive besides Ubuntu. It made 2 partitions out of it, one 100MB large for the system purposes, and another from the rest of the space for the rest of the system.

    2015. január 4.

    How to set up a Send to Kindle Button on Google Blogger

    1. Visit The Send to Kindle Button for Websites page to generate design and code for your button:
    http://www.amazon.com/gp/sendtokindle/developers/button

    When generating the code for your button select the "Blogger / Blogspot" option twice, if you do not use the dinamic view on your blog.
    If you use dinamic view, and you successfully install the Send to Kindle button on your blog, please do leave me a comment about how you did it! Thank you in advance!

    2.1. Go to your Blogger home: https://www.blogger.com/home
    2.2. Go to the Template menu of your blog.
    2.3. Select Edit HTML button under the Live on Blog thumbnail.

    3.1. Insert the "Step 1" code before the closing body tag.
    3.2. Change the "&" to "&amp;" in the code so the xml can understand it.
    3.3. Click Save Template to see that you do not get any errors. If you get errors, google on the error message to solve your problems.

    4.1. Insert the "Step 2" code in the "b:includable id='shareButtons' var='post'" section before the closing b:includable tag to have it together with the other shareButtons. (shareButtons have to be enabled from the Layout menu: edit Blog Entry and tick "Show Share Buttons".)
    4.2. Click Save Template to see that you do not get any errors. If you get errors, google on the error message to solve your problems.

    5. Check your blog, it now has a Send to Kindle button where ever you put it.

    2015. január 3.

    Plex Configuration for various reasons

    Restart Plex Server:

    ~$ sudo service plexmediaserver stop
    ~$ sudo service plexmediaserver start

    Install Plug-in manually:
    Plug-in directory: /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-ins/

    To install a new plug-in:
    the new plug-in's directory name should end with ".bundle" like the existing plug-in directories.
    copy the downloaded plugin to the plex plug-in directory
    ~$ sudo cp -R /download_dir/new_plug-in_dir /plex_plugin_dir/
    change the permissions to be like the existing plug-ins (this is not needed in 14.04 anymore)
    ~$ sudo chmod ugoa+rx /plex_plugin_dir/new_plug-in_dir
    change the owner of the files to be like the existing plug-ins
    ~$ sudo chown -R plex:plex /plex_plugin_dir/new_plug-in_dir
    restart plex server as written above.
    the new plug-in should show up in plex.

    Custom plug-in sources:


    works fine for me.


    To get AnimeToon working you need to update this file:
    AnimeToon.bundle/Contents/Services/URL/AnimeToon/ServiceCode.pys

    UPDATE: a fixed version of the plugin can be downloaded from here.

    Add these lines to the end of the file:
    
    ###new stuff begins
    
    elif each.find("videozoo") >= 0:
     page_data = HTML.ElementFromURL(each)
     string_data = HTML.StringFromElement(page_data)
     find_url = RE_PLAY44.search(string_data).group()
     url = String.Unquote(find_url, usePlus=False)
     Log(url)
     return [MediaObject(parts = [PartObject(key = url)])]
    
    elif each.find("playbb") >= 0:
     page_data = HTML.ElementFromURL(each)
     string_data = HTML.StringFromElement(page_data)
     find_url = RE_PLAY44.search(string_data).group()
     url = String.Unquote(find_url, usePlus=False)
     Log(url)
     return [MediaObject(parts = [PartObject(key = url)])]
    
    elif each.find("easyvideo") >= 0:
     page_data = HTML.ElementFromURL(each)
     string_data = HTML.StringFromElement(page_data)
     find_url = RE_VIDEO44.search(string_data).group()
     url = String.Unquote(find_url, usePlus=False)
     Log(url)
     return [MediaObject(parts = [PartObject(key = url)])]
    
    elif each.find("playpanda") >= 0:
     page_data = HTML.ElementFromURL(each)
     string_data = HTML.StringFromElement(page_data)
     find_url = RE_PLAY44.search(string_data).group()
     url = String.Unquote(find_url, usePlus=False)
     Log(url)
     return [MediaObject(parts = [PartObject(key = url)])]
    
    ###new stuff over
    

    2015. január 2.

    Serviio Configuration for various reasons

    Serviio promises features that require additional configuration and not work out of the box.

    Online Resources
    RSS feed reading requires the installation of serviio plugins, and that the feed be specifically readable for serviio.
    Online streaming my desktop with VLC could work, but definitely not through wifi (it is too slow for that)