2015. október 1.

Plex Plugin Installer

So, since I found plex plugin manual installation painfully boring, I wrote a nautilus script to do the job for me.
Instead of copy-pasting, you can also download this script form github.

I wasted a couple hours finding out that  if I use "double quotes" instead of 'single quotes' when assigning the plugin folder path to the PLUGIN_FOLDER variable, then 1.) the path will break on spaces and won't work; 2.) if I surround the call with '"'-s (a double quote between two single quotes) or just another "-s the program will fail not finding the files/directories. This was the tricky part because if instead of running I echoed the lines, they looked perfectly okay, and if I copy-pasted them to the command line they would even run properly... only not within a script.

#!/bin/bash
# nautilus script
# install PLEX plugin on Ubuntu 12.04.

# run this script by right clicking on the directory you want to install
install_plugin () {
 # standard feature: install by copying folder
 # future enhancement: install from ZIP file

 PARAMETERS=( "$@" )               ## array containing all params passed to the script

 PLUGIN_FOLDER='/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/'

 # read folder paths into TO_BE_INSTALLED
 IFS=$'\n' read -d '' -r -a TO_BE_INSTALLED < <(printf '%s\n' $PARAMETERS); unset $IFS

 need_to_restart_server=false

 for package in "${TO_BE_INSTALLED[@]}"; do
  package_name="${package##*/}" # Strip longest match of substring (*/) from front of string

 # sanity check: is the path correct? it should be a directory and end with ".bundle".
  if  [[ -d "$package" ]]; then # if selected path IS a directory
   if [[ "${package_name##*.}" == "bundle" ]]; then
    installed_package=$PLUGIN_FOLDER$package_name
   # check if plugin already exists
    if [[ -d "$installed_package" ]]; then 
     # if yes, ask to delete it 
     echo -n "A package with the same name is already installed. Would you like to overwrite it? (yes/no): "; read overwrite 
     if [[ $overwrite == [Yy][Ee][Ss] || $overwrite == [Yy] ]]; then 
      sudo rm -R "$installed_package"
     else
      echo "You chose not to overwrite $package_name so it will not be processed."
      continue
     fi
    fi
   # install plugin
    #copy the downloaded plugin to the plex plug-in directory
    sudo cp -R "$package" "$PLUGIN_FOLDER"

    #change the permissions to be like the existing plug-ins 
    #(this is not needed in 14.04 anymore)
    sudo chmod ugoa+rx "$installed_package"

    #change the owner of the files to be like the existing plug-ins
    sudo chown -R plex:plex "$installed_package"

    need_to_restart_server=true

   else # if not "bundle"
    echo "Package name should end with '.bundle'. $package_name will not be processed."
    continue # process next package instead
   fi

  else # if not directory
   echo "Package should be a directory. $package_name will not be processed."
   continue # process next package instead
  fi

 done
# when finished with all packages, restart plex server.
if [[ $need_to_restart_server = true ]]; then 
 sudo service plexmediaserver stop
 sleep 5
 sudo service plexmediaserver start
 
 echo "Installation complete. Your new plug-in should show up now in PLEX."
fi
}

export -f install_plugin

gnome-terminal --execute bash -c 'install_plugin "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"; bash'

2015. szeptember 2.

Firefox, AdBlockPlus and Ctrl+Shift+V


I use Ctrl+Shift+V (Paste as Plain Text) extensively overall. However I experienced that in Firefox instead of doing the Paste it opens a sidebar called "Blockable items on current page".

It turned out that this is because of the AdBlockPlus plugin.

To restore the Paste as Plain Text functionality you'll have to
  1. open the about:config page in Firefox, 
  2. search for the preference name extensions.adblockplus.sidebar_key 
  3. change the value of it to something else than Accel Shift V
  4. restart Firefox 
After doing these steps, you should have the Paste as Plain Text functionality back.

The solution comes from this source.

2015. július 3.

Very basic GitHub setup

Quick setup — if you’ve done this kind of thing before

git clone git@github.com:username/emptyproject.git

We recommend every repository include a README, LICENSE, and .gitignore.

 …or create a new repository on the command line

echo "# emptyproject" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:username/emptyproject.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin git@github.com:mdhtr/emptyproject.git
git push -u origin master

…or import code from another repository

You can initialize this repository with code from a Subversion, Mercurial, or TFS project.

Startup Applications do not stick, they get removed if I add them

As the user, you can set more startup applications from
gnome-session-properties
(Application Menu / System tools / Preferences / Startup Applications)

I added two new applications,
however, I noticed that they did not start on the next startup.

This was because they were not added permanently to the Startup applications.

and this was because my ~/.config/autostart forlder's write permission owner was the root.

I changed this with sudo chown -R myuser:myuser ~/.config/autostart

Probably running sudo gnome-session-properties would also have been enough, but I did not try.

Git Usage Tutorial

The essencial knowledge of using Git: a case study


Create your working directory and the file you will test git with:
mkdir github-test-project
cd github-test-project/
touch testfile.txt
echo "some text" >> testfile.txt

Initialize Git:
git init // Initialized empty Git repository
ls -a // lists all files in folder: there is now a .git directory.
git status // will show that you have one untracked file (testfile.txt) in your git Working Directory.

(Optional) Set up a local user name and e-mail for a project instead of the global:
git config --local user.name "username"
git config --local user.email "username@users.noreply.github.com"
// will overwrite your git --global settings for this directory. This way you can use different accounts for different git projects. You can confirm these local changes with the git config --local --list command.

Add remote server to the project (i.e. GitHub):
git remote add origin git@github.com:username/github-test-project.git // to add remote named "origin". You can rename your remote to anything you like, but with "origin" you have the privilege to use git push without specifying the remote.
git remote -v // to list added remotes by name with address

The standard usage:

Working Directory and Staging Area or Index (add)
//you have one untracked file (testfile.txt) in your git Working Directory.
git add testfile.txt // adds the file to the Staging Area (aka Index)
echo "and some more text" >> testfile.txt //you change something on the file, and now you have a tracked and an untracked version of your file in git status
git add -u // adds the changes to the files that are already tracked but does not add untracked files to git. now you have - yet again - a single file shown by git status
git reset testfile.txt // un-add file = remove file from index = the opposite of git add file. If you do this, the test file will be listed as untracked one again.

Local Repository (commit)
// this is the point when making mistakes get nastier.
git commit -m "first version of testfile" // commits all your indexed (added) files with the message specified in -m "". Now testfile.txt is in the local repository, and git status shows no "to-be-committed" files.
gitk // check out the commit in the repository browser
git commit --amend // if you realize you want to change your commit message, this can happen right after you commited.

touch newtestfile.txt
git add newtestfile.txt
git commit --amend // if you want to add some new files to your last commit (you can also change the commit message this way) -- now both testfile and newtestfile will be in your first commit.
git update-ref -d HEAD // if you want to undo your initial commit (NOT RECOMMENDED!). This will not bring back the state before the initial commit, only delete the HEAD (master), so it seems as if no commit has been made in this project yet. You could also delete your .git directory and start over from scratch.

//let's add some more commit to see the proper undo method for commits
echo "some other text" >> newtestfile.txt
git add -u
git commit -m "this is the second commit" // now gitk shows already two commits
echo "some more txt" >> testfile.txt 
git add testfile.txt  // this is the last indexed file
echo "some more txt" >> testfile.txt // this is the last untracked change
git reset --soft HEAD~ // will undo the last commit in the sense as if it did not happen at all, but does not change the indexed and untracked files.

// DANGER ZONE (not Working Directory safe!)
// reverting untracked changes = overwriting with last tracked (added/indexed) version
echo "some more txt I will permanently undo" >> testfile.txt
git checkout -- testfile.txt

// DANGER ZONE (not Working Directory safe!)
// reverting commits and uncommited changes = overwriting with commited version
echo "some more txt I will permanently delete" >> testfile.txt 
git add testfile.txt 
git commit -m "a commit I will permanently delete" // this is my last commit
echo "some more txt" >> testfile.txt 
git add testfile.txt  // this is the last indexed file
echo "some more txt" >> testfile.txt // this is the last untracked change
git reset --hard HEAD // will delete everything since the last commit
git reset --hard HEAD~ // will delete everything since the before-the-last commit (it will also delete the last commit)

Upstream or Remote Repository (push)
// you have to create the remote repository before you can push to it. On GitHub this can only be done manually through your profile on the website.
git push -u origin master // the very first time you push, you have to specify remote name (origin) and branch name (master) for further usage. The -u sets the remote to be the upstream.
git push // can be used in further cases with default to origin and master.
gitk // now shows the remote branch head status

// community remote repositories exist so more people may work on the same code.
// this is when the terms merge, rebase, fork, etc. come in picture
// the thing with remotes is that they will be always upstream (chronologically behind you). This is why you have to change your local repository first, to be able to make changes on the remote.

// local-repository-safe removal of remote repository commits
git reset --soft HEAD~ // remove the last commit, as written above
git push -f // -f is for force

// this will ruin your local commit-history!
git update-ref -d HEAD // deletes the local HEAD
git reset . // remove all indexed files
touch readme.txt // you'll have to add something to git to have the HEAD position back
git add readme.txt// it can be any file you want
git commit -m "initial commit" // now you have a HEAD again
git push -f // since you have a HEAD, you can reset the remote HEAD with it.
// now you could delete the remote repo if you want (on GitHub you have to do this by hand)
// I think it is generally a good idea to initialize a new project with some uninteresting files, to have a commit history to refer to.

//to be continued with merge, rebase, fork, etc...
// use interactive rebase to clean up commit history before pushing to remote.
// with interactive rebase it is possible to rewrite all of your commit messages to be more informative (before pushing to remote). it is a great tool, but use with extreme care!

// to write formatted text for a readme of wiki page this is the reference

Getting started with Git

Git Basics
  • Git thinks of its data more like a set of snapshots of a miniature filesystem
  • if files have not changed, Git doesn’t store the file again, just a link to the previous identical file it has already stored
  • you have the entire history of the project right there on your local disk
  • there is very little you can’t do if you’re offline
  • it’s impossible to change the contents of any file or directory without Git knowing about it (Everything in Git is check-summed before it is stored)
  • Git stores everything in its database not by file name but by the hash value (40-character string used for checksumming) of its contents
  • It is hard to get the system to do anything that is not undoable or to make it erase data in any way
  • Git has three main states that your files can reside in: committed, modified, and staged 
    • Committed means that the data is safely stored in your local database
      • your local database is called the "Git Directory" ("Repository"). This is what is copied when you clone a repository from another computer
    • Modified means that you have changed the file but have not committed it to your database yet
      •  this happens in your "Working Directory". The working directory is a single checkout of one version of the project.
    • Staged means that you have marked a modified file in its current version to go into your next commit snapshot 
      • the Staging Area is a file, generally contained in your Git directory, that stores information about what will go into your next commit
  •  The basic Git workflow goes something like this:
    • 1. You modify files in your working directory.
    • 2. You stage the files, adding snapshots of them to your staging area.
    • 3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
Get the latest Git version installed:
  • Add the latest git version to your repository:
    • sudo add-apt-repository ppa:git-core/ppa 
  • Update repository list:
    • sudo apt-get update
  • Install the latest version of git:
    • sudo apt-get install git
  • Check git version:
    • git --version
Essential Git setup after installation
Set up an SSH key to use with GitHub

Get help:
  • there is a general man page and 
  • there are also separate man pages for each command.
  • Check out the Git CheatSheet
  • install GitK for a visual Git history browser

2015. július 1.

Removing text watermark from PDF

Following this guide, the solution for me was:
  1. Fix your PDF, just in case:
    pdftk original.pdf output fixed.pdf
  2. Uncompress your PDF for text manipulation:
    pdftk fixed.pdf output uncompressed.pdf uncompress
  3. Remove text watermark with SED:
    sed "s/Wow! eBook <WoweBook.Com>/ /g" uncompressed.pdf > unwatermarked.pdf
  4. Compress the edited PDF:
    pdftk unwatermarked.pdf output compressed.pdf compress
As usually, I had trouble using SED.
It turned out that sed -e "s/Wow! eBook <WoweBook.Com>/ /" did not work for me, but somehow the one without the -e option and with the /g flag did.

2015. június 12.

Ubuntu 14.04 tray icons for Skype and Rescuetime

On a 64-bit Ubuntu 14.04 to be able to see the tray icons for Skype or Rescuetime or other 32-bit application, install the sni-qt:i386 package. Source: Askubuntu.

sudo apt-get install sni-qt:i386

2015. június 5.

How to install Sigil ePub editor on Ubuntu 12.04

Sigil, the best ePub e-book creation and editor tool I know, has no longer an official Linux version.
However, it is still possible to get a native copy running on your Ubuntu.
Please refer to this askubuntu post if the below method does not work for you (because it is probably already outdated).

On Ubuntu 12.04:
You'll need to add two repositories, one for Sigil and one for a dependency, then update repos, and install:
sudo add-apt-repository ppa:sunab/sigil-git
sudo add-apt-repository ppa:beineri/opt-qt521
sudo apt-get update
sudo apt-get install qt52base qt52webkit
sudo apt-get install sigil

2015. június 4.

How to downgrade packages?

I upgraded packages from gnome3-team by mistake (forgot to take out the ppa), and I wanted to downgrade them (back to the official stable version).

ppa-purged worked for me in this case:
sudo ppa-purge ppa:gnome3-team/gnome3

I got this information from this superb askubuntu post

Dropbox installation on Ubuntu 14.04.2 LTS with problem solving

Somehow Dropbox does not want to work for me on laptops...

so,

1. ) install nautilus-dropbox from apt

sudo apt-get install nautilus-dropbox

2.) solve permission issue (if present):
find out where dropbox launcher is stored:
which dropbox
edit the path you got from which command (for me it is /usr/bin/dropbox )
sudo gedit /usr/bin/dropbox
find the line causing the permission issue (looking at the wrong place for dropbox):
PARENT_DIR = os.path.expanduser("/var/lib/dropbox")
change it to your home directory (the daemon will be installed here)
PARENT_DIR = os.path.expanduser("~")
save the file.

3.) install dropbox from dropbox official site through ppa repository
sudo sh -c 'echo "deb http://linux.dropbox.com/ubuntu/ trusty main" >> /etc/apt/sources.list.d/dropbox.list' sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5044912E sudo apt-get update sudo apt-get install dropbox

4.) restart nautilus
nautilus --quit

5.) start dropbox with daemon install
dropbox start -i

6.) add notification area to gnome-panel (if not present):
Super+Alt+RightClick panel > Add to panel... > Notification Area

Hopefully, everything is working now without any kind of unexpected messages.

2015. június 2.

How to install Oracle Java 1.7 and 1.8 on Ubuntu 14.04?

Install Java version 1.7

Install Java version 1.8

via PPA:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo apt-get install oracle-java8-installer

Set Java 1.7 as default version:
sudo update-java-alternatives -s java-7-oracle

To set environmental variables to Java 7, install:
sudo apt-get install oracle-java7-set-default

Configuring Gnome Flashback with Compiz compared to Metacity

1. Install Compiz Config Settings Manager
sudo apt-get install compizconfig-settings-manager
2. Set number of workspaces:
in Compiz Config Settings Manager go to General / General Settings / Desktop Size
set the size you want.
3. Get to know Compiz Plugins
you might find that not everything is installed by default what you want to use. in this case find out which package contains your plugin and install it.

2015. május 24.

My Ubuntu Phone App Wishlist

My source for getting up to date with the important and available apps for ubuntu phone is this post on Sturmflut's blog.

Based on my usage of any kind of smartphone, this is my list (might not be complete):

Phone Core:
what I think every smartphone should have, and their (--> specific android apps) I use.
  • System Settings
  • Phone Dialler
  • Messaging (SMS, MMS)
  • Address Book ( --> Google Contacts)
  • Clock, Alarm, Timer, Stopwatch
  • Calculator
  • Torch
  • FM Radio 
  • Camera (Photo, Video recording)
  • Dictaphone (Sound recording)
  • File Manager
  • Gallery (Image Viewer)
  • Document Viewer / E-Book Reader ( --> Adobe Reader, Kindle)
  • Music playback
  • Video playback
  • E-mail Client ( --> Gmail)
  • Calendar ( --> Google Calendar)
  • Tasks ( --> Google Keep (GTasks))
  • Notes ( --> Google Keep)
  • Internet Browser ( --> Google Chrome)
    • There is Browser (Ubuntu Core App)
  • Internet Radio ( --> Xiia Live)
    • There is uRadio. You have to add stream url-s to it. Playlist files will not work, but stream urls work fine. 
  • Podcast Manager 
  • RSS reader
  • Weather ( --> AccuWeather.com)
  • Dictionary ( --> Google Translate)
  • GPS Navigation / Maps / Compass ( --> Google Maps, GPS Essentials)
    • There is HERE Maps (preinstalled)
    • There are two Google Maps webapps: one & another.
  • Platform integrated Sharing and Push Notifications
  • Platform integrated Social Media Accounts (user name and password handling in apps and on websites too)
Specific Android Apps:
what I would like to use on my smartphone.

Communication:
File synchronization and online access:
 NetBanking:
  •  CIBm Token
Time logging:
  • Toggl

Games and for fun:
  • Google Sky Map
  • Go Free, Mouse
  • Guitar tuner
  • Instagram, Pixlr-o-matic
Tools and Utilities:
  • Noise Meter
  • Terminal
Phone backup and restore:
  • Call Logs Backup & Restore
  • SMS Backup & Restore

2015. május 22.

Digging deeper into the Ubuntu Phone

Just a list of links


Slides:
Ubuntu Phone Engineering:
http://www.slideshare.net/chihchun/ubuntu-phone-engineering
Ubuntu HTML5 apps deep dive
http://www.slideshare.net/DavidPlanella/ubuntu-html5-apps-deep-dive

Hacking Ubuntu Touch - a series of posts:

https://sturmflut.github.io/ubuntu/touch/2015/05/07/hacking-ubuntu-touch-index/

How hard can it be to make a new app for the Ubuntu Phone?

Some essential knowledge before taking any further steps.

Developers get the full support they need

Welcome to Ubuntu apps development! -- an outline of the contents


Design comes first: Apps design guidelines.
Get started with the Ubuntu SDK:

Understanding the Ubuntu App Platform: The Ubuntu Platform Guides
Picking your app toolkit:   
Publishing your app

Connection the Ubuntu Phone to the Ubuntu Desktop

Sadly, if you connect the Ubuntu Phone with an USB cable to the Ubuntu Desktop PC, it just might not show up in Files/Nautilus.

On Ubuntu 14.04 the problem can be solved by installing the latest libmtp on the Ubuntu Desktop.
As written in this askubuntu answer:
sudo add-apt-repository ppa:fossfreedom/libmtp
sudo apt-get update
sudo apt full-upgrade

On Ubuntu 12.04 it is not this easy.

To install the latest libmtp, use these commands instead of the above:
sudo add-apt-repository "deb http://ppa.launchpad.net/fossfreedom/libmtp/ubuntu trusty main" 
sudo add-apt-repository "deb-src http://ppa.launchpad.net/fossfreedom/libmtp/ubuntu trusty main"
sudo apt-get update
sudo apt-get dist-upgrade

However, the Ubuntu Phone still not shows up in Nautilus.
But it is definitely recognized in lsusb:
~$ lsusb
Bus 001 Device 004: ID 2a47:2008 

ADB: an alternate way

An alternate way to reach the phone in with the Android Debugging Bridge (adb).
Install adb, if you don't have it yet:
sudo apt-get install android-tools-adb 

To be able to use the adb with the Ubuntu Phone, turn on Developer Mode on your phone.
Go to 'Apps > System Settings > About this phone > Developer mode' and turn it on. You'll have to set a Lock security first if you use Swipe only to unlock your phone.

As written in this askubuntu post, you'll have to add the phone vendor manually to the list adb recognizes, and then restart the adb-server:
printf '0x2a47\n' > ~/.android/adb_usb.ini
sudo adb kill-server;  sudo adb start-server

Now the Ubuntu Phone is recognized by adb:
~$ adb devices
List of devices attached 
JU013288 device

Usage of adb:
As a regular user, you'll probably just want to move files around.
This can be done with the push and pull commands.
Push copies a specified file from your computer to the phone.
adb -d push <local> <remote>
For example:
adb -d push ~/Music/testfile.mp3 Music/
Pull copies a specified file from the phone to your computer.
adb -d pull <remote> [<local>]
For example:
adb -d push Music/testfile.mp3 ~/Music/
List files and directories of your phone:
~$ adb -d shell ls
Documents  Downloads  Music  Pictures  Videos

~$ adb -d shell ls Music/
testfile.mp3

Mass-copy files with adb:
With adb it is impossible to mass-copy files. There is a sync option, but it only updates files that already exist, and copies none.
Alternate ways are script and tools based on adb, for example:

2015. május 20.

Ubuntu Phone Support and Bug Reporting

Before reporting bugs, always search for the bug you want to report. It is probably already known, and you only have to add yourself to it.
Check for reported bugs on the right side column on this site:
https://wiki.ubuntu.com/Avengers

First bugs:

Getting Started with the Ubuntu Phone

Some essential knowledge



Ubuntu Touch is the operating system of the Ubuntu Phone.
 
Read the Help!
Definitely read the Help! It can be downloaded from the Store.
Also read the FAQ for info like dual booting Ubuntu with Android on your phone, and that you cannot install GUI based Ubuntu Desktop applications on the Ubuntu Touch/Phone, because the GUI is different.

What is the difference between Scopes and Apps?
If I understand correctly, Scopes are made for showing content to the user, and making search easier.
Compared to Scopes, if I understand correctly, only Apps allow the user to both receive and share content, while Scopes only allow to receive.
For example: you have the Instagram scope this day, in which you can view other people's Instagram images. But you do not have the official Instagram application, so you cannot make new Instagram images and you cannot upload them to Instagram.

What is the difference between WebApps and Apps?
WebApps are simply a website optimized for viewing on the Phone. They looks like an App, but they are really not, mainly because they mostly lack integration with the phone. (i.e. share options)

Not all Ubuntu Phone Core Apps are preinstalled:
You have to install manually from the App Store:

  • File Manager
  • Document Viewer
  • Calendar
  • Terminal

Reporting Bugs of the Phone:
http://askubuntu.com/questions/602162/how-should-i-report-bugs-in-my-bq-ubuntu-phone
refers to: https://wiki.ubuntu.com/Avengers

PC-accessible AppStore content:
https://uappexplorer.com/

Copying files to and from the phone:
Through Nautilus/Files only Documents, Downloads, Music, Pictures and Videos folders are reachable. If nothing happens when you connect your phone, try this.
An alternate way to push and pull files is using ADB, which is an android development tool. If you have trouble getting the device recognized, try this. Developer mode has to be enabled to reach the device with ADB. (And here's how to set up ssh connection)

The Starting Sites for Developers:
http://www.ubuntu.com/phone/developers
http://developer.ubuntu.com/en/
More on Scopes: https://developer.ubuntu.com/en/scopes/
More on Apps: https://developer.ubuntu.com/en/apps/

2015. május 18.

Welcome to the Ubuntu Phone

I got my hands on a BQ Aquaris E4.5 Ubuntu Edition.

This is the hardware specification:

Screen
  • Screen size: 4,5"
  • Screen Technology: Capacitive IPS multi-touch screen with 5 simultaneous-detection points
  • Screen resolution: qHD 540 x 960 px, 220 HDPI
  • Aspect ratio: 16:9
  • Viewing angle: 178º
  • Others: Dragontrail Protection Glass
Memory
  • Internal mechanics: 8 GB eMMC
  • Expandable memory: Via microSD™ card (up to 32 GB)
Battery
  • Battery: LiPo 2150 mAh
Supported Formats
  • Video formats: .avi, .mkv, .mov, .mp4
  • Audio formats: .mp3, .ogg, .wav
  • Image formats: .bmp, .gif, .jpeg, .png
  • Text formats: .pdf, .txt
Dimensions and weight
  • Weight: 0.1230
  • Dimensions: 137 x 67 x 9 mm
Operating System
  • OS: Ubuntu
Connections
  • Connections: 3.5 mm headphone jack, Dual Micro-SIM
Functions
  • Functions: Ambient noise cancellation, FM radio, Microphone, Notification LED, Proximity sensor
Processor
  • RAM: 1 GB
  • CPU: Quad Core Cortex A7 up to 1.3 GHz
  • GPU: Mali 400-MP2 up to 500 Mhz
Camera
  • Front camera: 5 Mp
  • Rear camera: 8 MP with autofocus and flash
Connectivity
  • Bluetooth: Bluetooth®
  • Wi-Fi: Wi-Fi™ 802.11 b/g/n
  • 3G: 3G + (HSPA+/UMTS/GSM)
It has 2 Micro SIM slots, so the first thing to do was to cut down my regular sized SIM card to a MicroSim.
Here's how: http://smartphones.wonderhowto.com/how-to/cut-your-sim-card-down-mini-micro-nano-size-0149154/

I changed from using Android, and everything is looking good so far:
  •  I could set up Google accounts for Mail and Contacts sync
Here's the problems I ran into:
  • Q: Google Calendar is not present to sync. How to change this?
    this post shows that there could be a checkbox for Calendar, but I see none.
    • A: Have to install Calendar Application from Store first. Then it is possible.
  • Q: GPS location is off by 30 km. How to make it more exact? GPS is not really working, i.e. 'Here' cannot find my location.
    • A: this solved itself after some time.
  • Bluetooth is either turned off or discoverable. How to set it hidden, while keeping it turned on?
  • Q: How to set the Weather measurements to Celsius and meter on the Today scope? Why is it in Fahrenheit?
    • A: This depends on the Region you set for your phone. English (US) will use imperial and Fahrenheit, and English (UK) will use metric and Celsius.
    • This probably changes the Spelling auto-correction too, but I will not use it anyway.
Some of my essential apps I would want to use on Ubuntu Phone too:
  • Facebook messenger
    • opening m.facebook.com/messages in the browser is a huge help
  • Google Tasks
  • Google Keep
After the first afternoon with the dual SIM UbuntuPhone I quickly went back to using the previous Android device for The Phone For Work, as my professional life requires the usage of a variety of stable Android apps, which UbuntuPhone currently cannot provide.

However, as my private phone, Ubuntuphone will probably be a lot of fun :)

Ideas to check out:
  • Android emulator for UbuntuPhone
  • Python and Bash: what is possible on the phone with scripts?
  • General knowledge on the dev possibilities
  • Installing desktop apps like Facebook Messenger
  • Creating Web Apps like Facebook Messenger
Some interesting links on development and dev tools and so on:

2015. április 30.

color to grayscale PDF

The source file:
a PDF with page size US letter portrait
with text layer (different color and text background varying)
with color images as background (many images sum up to one background picture

The quest: convert the source PDF to:
a PDF with page size A4 portrait
with or without text layer (flatten or not - but keep text readable)
with grayscale and/or black and white (but recognizable) images as background

The purpose: print out the pdf on a regular black-and white printer:
keep it readable, and esthetically enjoyable
do not use more ink than necessary

***
The routes I tried:

1.) (from under the text layer) extract images, convert images, put images back.

Toolkit:

Extract images:
pdf2htmlEX --embed cfijo example.pdf

Convert images:
mogrify -type Grayscale -format ps *.png

...convert back to pdf with ps2pdf, join with pdfjoin or pdftk

Extract text layer:  
cpdf -draft example.pdf -o example_text.pdf

Put background images behind text layer:
pdftk  example_text.pdf multibackground example_images.pdf output modified.pdf


2.) flatten PDF to images, edit images.

Toolkit:

Burst pdf to single pages:
pdftk example.pdf burst

Convert to PostScript:
pdftops (and not pdf2ps)

Flatten ps to pnm and edit image
mogrify -format pnm -density 200x200 -type grayscale *.ps

...convert back to pdf with ps2pdf, join with pdfjoin or pdftk



***
In the end I chose the second route, because I had some trouble with the fonts in the pdf, which were not exported properly, and left a black text box in the images (making the text unreadable after backgrounding back to pdf)

Also the first route would involve a lot of learning of the PDF structure, the layer manipulation, and so on.

2015. április 26.

How to turn off ubuntu overlay scrollbar

https://www.liberiangeek.net/2012/03/disable-ubuntu-overlay-scrollbars-in-ubuntu-12-04-precise-pangolin/

~$ gsettings set org.gnome.desktop.interface ubuntu-overlay-scrollbars false

This can be set by hand in dconf editor:

org > gnome > desktop > interface > ubuntu -overlay-scrollbars [remove checkmark]

2015. április 8.

Command Line alternative to Safely Remove Drive

Recently my external USB drives (HDD, Pendrive, Kindle, mobile phone) stopped detaching itself after unmount.
Obviously I would not plug out a HDD with 750GB data that is still spinning. But it does not want to stop at all. I can mount and umount it and it is still spinning. (Or whatever these new drives does instead of spinning)

So the solution is to do the command line equivalent of safely remove in two steps:
1. unmount
2. detach

The solution I found on askubuntu:

For a practical example, if I have the partition /dev/sdb1 mounted, I would run this to unmount and detach it:
udisks --unmount /dev/sdb1
udisks --detach /dev/sdb

2015. február 27.

PDF to HTML for eBook creation

My general goal is to process PDF files through a HTML/XML state before making eBook (mobi/epub) from them.
So the goal is, to somehow generate a clean HTML file out of a PDF.
Some of my general needs are:
  • keep paragraphs together (not mixing up <br /> with <p></p>)
  • get images and text together
  • keep character formatting
  • handle multiple columns (convert to single column)
  • skip page numbers
First of all, here's what I found important from the Google search results:

Thomas Levine's Parsing PDF files walk-through
Tools to use:
  • Basic file analysis tools (ls or another language’s equivalent)
  • PDF metadata tools (pdfinfo or an equivalent)
  • pdftotext
  • pdftohtml -xml
  • Inkscape via pdf2svg
  • PDFMiner
My own experiments:
With this PDF file, and another one that I made for this purpose.


PDFtoHTML
$ pdftohtml example.pdf
  • incorrectly displayed character encoding
    • <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"> has to be entered in the HTML HEAD for proper character encoding 
    • could put a -enc UTF-8 (Case Sensitive!) as an option if needed, but the header meta still has to be entered manually. 
    • the meta gets entered in the document if the -noframes option is used.
  • no paragraphs, only breaks
  • a navigation html file was generated with two frames: one for a page index html, and one for the actual text.
    • this can be avoided using the -noframes option
    • the -s option to generate single output (however this will only concatenate the whole html files, and links are not corrected)
  • pages are separated with horizontal rulers
  • images are processed all right
 $ pdftohtml -c example.pdf
  • formatting is mostly strictly preserved
    • styles by css
    • absolute positions of paragraphs
      • some paragraphs are kept together, some are not recognized properly
    • left text alignment is the only one that is kept, everything else is shown with absolute left position.
    • bold and italics is preserved, but underline shows wrong
    • columns are preserved okay
    • font face changes do not show.
  • images are embedded in page background
  • every page is a separate html file
$ pdftohtml -xml example.pdf
  • stores formatting info about absolute positions, font size and line height
  • no info about paragraphs, images
Alltogether experinece with PDFtoHTML: it's almost good for nothing, when it is not processed properly afterwards.

Postprocessing a file generated with the pdftohtml -enc UTF-8 -noframes -p -q example.pdf command:
Sturcture:
  • style element and some meta element in the html head are unnecessary.
  • <a name=[pagenunber]></a> marks the beginning of every page
  • <br/> in the middle of a line marks line break
  • <br/> at the end of the line marks paragraph break
  • <hr/> marks the end of every page
  • the last line before the end of page is probably a page number
PDFMiner
Download and Install PDFMiner.
Review the command line tools and their capacity.

$ pdf2txt.py -o example.html  example.pdf
or
$ pdf2txt.py -Y normal -o example.html  example.pdf 
  • no paragraphs, only breaks
    (paragraphs are not collected -- no easy way to restore them, unlike in pdftohtml)
  • formatting is not css but html span tags
    • Html Tidy can collect the formatting to the front of the html file as css, making it easier to review and modify:
      tidy -utf8 -c -o example_tidy.html  example.html
  • bold and italics are kept as font family style in span tag, underline is taken as an image (?)
  • images not processed
  • display is messy, text displayed on top of each other
  • code is quite all right.
$ pdf2txt.py -o example.xml  example.pdf
or
$ pdf2txt.py -Y exact -o example.html  example.pdf 
  • stores exact position of every single character
  • holds space for images
$ pdf2txt.py -t tag -o example.txt  example.pdf
  • stores pdf page data, with unformatted text content
$ pdf2txt.py -Y loose -o example.html  example.pdf
  • does not keep the line breaks, only the span style is present to indicate text changes. paragraphs not recognized properly
  • messy code
Alltogether experinece with PDFMiner: this is not what I'm looking for. It either store too much or too little information for my purposes, so in my case it's actually good for nothing, when it is not processed properly afterwards.


pdf2htmlEX
$ pdf2htmlEX example.pdf
  • omg wow amazing pretty output view!
    • everything looks exactly like the pdf file
  • (in exchange for an) extremely messy code :)
    • one page is one line, identified by a (div) id.
    • formatting is kept in classes (div, span, img, ...) by CSS:
      • @font-face {}
      • @media {}
      • .ff: font-family
      • (t) m: transformation matrix
      • v: vertical-align
      • ls: letter-spacing
      • sc: text-shadow
      • ws: word-spacing
      • _: display and width or margin-left
      • fc: color
      • fs: font-size
      • y: bottom
      • h: height
      • w: width
      • x: left
  • all file embedding can be turned off with --embed cfijo (will generate separate output files)
Alltogether useless for my purposes.However, the best if your purpose is to display a pdf file as a html page on the web.

PdfMasher (GUI)
Does not keep formatting or images, but is specialized to keep proper order of the text.
  • as said, does not keep font formatting or image placeholders
  • with a little manual adjustment:
    • can be set to ignore page numbers (amazing!)
    • can be set to collect and link footnotes to be endnotes (amazing!)
  • html code is quite clear
  • paragraphs are well kept if it was possible
Alltogether so far this is the best tool to prepare a simple text pdf for eBook creation.
Usage:
There are five type of elements that can be set in Edit mode:
  • Normal: will be default text
  • Title: will be Header tag H1 for once pressed, H2 for twice pressed, etc.
    • best to be filtered with sorting by Font Size
  • Footnote: will search for the reference and link it as endnote
    • best to be filtered with sorting by Font Size (or X or Y, respectively)
  • Ignore: will be ignored
    • Page numbers, footers and headers are best to be filtered with sorting by Y (or X, respectively)
  • To Fix:puts a FIXME sign in front of the paragraph. In HTML this becomes an italics formatted text.
These types can be set on the Table or on the Page tab.
Build options are:
  • Generate Markdown: generates a plain text file in the pdf directory with marks specifying the Title and To Fix parts, Ignored elements already ignored, and Footnotes already linked.
  •  Edit Markdown: opens the markdown text file
  • Reveal Markdown: opens the directory in the default file browser containing the markdown
  • View HTML: generates the html file out of the markdown file, and opens it in the default web browser
Markdown signs:
  • # for H1, ## for H2, etc.
  • *FIXME* for italics
  • *** for horizontal ruler  
  • numbers for lists (quite annoying)
  • more on markdown usage
  • I accidentally found an eBook creation software that works from text like this markdown text, so I'll just leave a link here for notice.
Formatting of the text can be fixed manually in the markdown form or in the html form.
When saving as MOBI or EPUB there will be Table of Contents and navigation generated from the headings. The book Start will be set to the first heading.

Summary:
  • To export all images from your file for further usage,
    use pdf2htmlEX --embed cfijo example.pdf.
    • can be opened in LibreOffice
  • To get a very simple html with proper paragraphs, endnotes, and headings, but without font formatting,
    use PDFMasher (GUI).
  • To get a fair html code with most of the images and font formatting but messed up paragraphing,
    use pdftohtml -enc UTF-8 -noframes -p -q example.pdf
    • cannot be opened in LibreOffice
That's it for so far.
Probably the best way would be to learn SED and create a html cleaning script for myself, but that's likely distant future.

2015. február 25.

PDF smart rename and split based on content


I was planning to do these scripts for some time to ease my work with pdf files.

The original idea was to grep some text from the pdf file and do a file manipulation based on the text.

This StackExchange post suggests the following methods to find a piece of text in a pdf:
  • pdftotext + grep
  • pdfgrep
  • strings + grep
  • pdftohtml + grep
I used pdftotext in the following examples.

I also needed to learn some more Bash scripting:
1st Quest
I have a monthly employee data sheet (payroll), which I get in one big multipage pdf file, having a single page for each employee. The content for each page is: 1st line: title, 2nd line: month, 3rd line: employee name.
I wanted to burst this pdf file into single pages and rename it to title month and employee name.
My solution is:
#!/bin/bash
# NAUTILUS SCRIPT
# automatically splits pdf file to single pages while renaming the output files using the first three of lines of the pdf

# read files
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS

pagecount=1
datestamp=1

# burst and rename pages to separate files
for file in "${filelist[@]}"; do
 pagecount=`pdfinfo $file | grep "Pages" | awk '{ print $2 }'`
 for (( pageindex=1; pageindex<=$pagecount; pageindex+=1 )); do
  newname=`pdftotext -f $pageindex -l $pageindex $file - | head -n 3 | tr '\n' ' ' | cut -f1 -d"("`
  let "datestamp =`date +%s%N`" # to avoid overwriting with same new name
  pdftk $file cat $pageindex output "$newname"$datestamp.pdf
 done
done

2nd Quest
I have files I would like to rename based on the content of the file. Each file is some kind of employee data file, and has the employee name in the content, but not necessary in the file name.
I wanted to rename the file based on the employee name and the page title (first line of the file).
My solution is:
#!/bin/bash
# NAUTILUS SCRIPT
# automatically renames pdf file based on content maching a list of names

# read files
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS

names=( "Aaa Aaa" "Bbb Bbb" "Ccc Ccc") # names to match in the files

# process files
for file in "${filelist[@]}"; do
 # find name from names in the file
 foundname=''
 for name in "${names[@]}"; do
  testname=`pdftotext "$file" - | grep $name`
  if [[ $testname != "" ]]; then
   foundname=$name
   break
  fi
 done

 # rename file based on found name
 title=`pdftotext -f 1 -l 1 "$file" - | head -n 1`
 let "datestamp =`date +%s%N`"
 mv "$file" "${file%/*}/$foundname $title $datestamp.pdf"
done

3rd Quest
I have a yearly employee data sheet (personal tax data), which I get in one big multipage pdf file, having a multiple pages for each employee. This year it is three pages per employee, but the tax ID number is the only common point in the three pages (it it a 10 digit long number beginning with number 8). The first line of each page is a header, and it is different for each page for a single employee.
I wanted to split the pdf to employees and rename it with the header of the pages.
My solution is:
#!/bin/bash
# NAUTILUS SCRIPT
# automatically splits pdf file to multiple pages based on search criteria while renaming the output files using the search criteria and some of the pdf text.

# read files
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS

# process files
for file in "${filelist[@]}"; do
 pagecount=`pdfinfo $file | grep "Pages" | awk '{ print $2 }'`
 # MY SEARCH CRITERIA is a 10 digit long ID number that begins with number 8: 
 storedid=`pdftotext -f 1 -l 1 $file - | egrep '8?[0-9]{9}'`
 pattern=''
 pagetitle=''
 datestamp=''

 for (( pageindex=1; pageindex<=$pagecount; pageindex+=1 )); do

  header=`pdftotext -f $pageindex -l $pageindex $file - | head -n 1`
  pageid=`pdftotext -f $pageindex -l $pageindex $file - | egrep '8?[0-9]{9}'`
  let "datestamp =`date +%s%N`" # to avoid overwriting with same new name

  # match ID found on the page to the stored ID
  if [[ $pageid == $storedid ]]; then
   pattern+="$pageindex " # adds number as text to variable separated by spaces
   pagetitle+="$header+"

   if [[ $pageindex == $pagecount ]]; then #process last output of the file 
    pdftk $file cat $pattern output "$storedid $pagetitle $datestamp.pdf"
    storedid=0
    pattern=''
    pagetitle=''
   fi
  else 
   #process previous set of pages to output
   pdftk $file cat $pattern output "$storedid $pagetitle $datestamp.pdf"
   storedid=$pageid
   pattern="$pageindex "
   pagetitle="$header+"
  fi
 done
done

4th Quest
I wanted to have an alternate version of the 3rd Quest in case I have to split in equal sets of pages any other type of file, not having the tax ID as a common point in them.
So I wanted to split this multipage pdf based on a manually set block size, i.e. 3 pages / set.
My solution is:
#!/bin/bash
# NAUTILUS SCRIPT
# automatically splits pdf file to multiple pages based on given block size, and renames the files using the original filename plus datestamp

# read files
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS

# process files
for file in "${filelist[@]}"; do

 # variables
 blocksize=3 # ADD BLOCK SIZE MANUALLY HERE
 blocks=()
 filename=${file%.pdf} # remove extension from filename

 # calculate page range blocks
 pagecount=`pdfinfo $file | grep "Pages" | awk '{ print $2 }'` 
 let setcount=$pagecount/$blocksize 
 for (( setindex=1; setindex<=$setcount; setindex+=1 )); do

  if [[ $setindex -lt $setcount ]]; then
   let lastpage=$setindex*$blocksize
   let firstpage=$lastpage-$blocksize+1

  elif [[ $setindex -eq $setcount ]]; then # handle last page
   let lastpage=$pagecount
   let firstpage=$setindex*$blocksize-$blocksize+1

  fi
  blocks+=("$firstpage-$lastpage")
 done

 # process ranges to output
 for block in "${blocks[@]}"; do
  let "datestamp =`date +%s%N`" # to avoid overwriting with same new name
  pdftk $file cat $block output "$filename $datestamp.pdf"
 done
done

That's it. Could be better, but is functioning all right.

2015. február 19.

Using NCX-generator on Wine

NCX-generator is a Windows Command Line Interface utility to prepare e-books for processing with Kindlegen.

ncx-generator can be used through Wine. It requires .NET Framework 4 to be installed.

ncx-generator have to be run through Wine's Console User Interface (wineconsole - installed with the wine package).

This is the help file:

ncxgen [options] filename

  -h, -?, --help             Display this help.
      --toc                  Generate the html Table of Contents.
      --ncx                  Generate the NCX Global Navigation.
      --opf                  Create the opf file package.
  -a, --all                  Create both html ToC, ncx and opf files.
  -q, --query=VALUE          The XPath query to find the ToC items. Use
                               multiple times to add levels in the ToC.
  -l, --level=VALUE          Number of levels to collapse to generate the NCX
                               file - used with -ncx or -all.
  -e                         Place the generated TOC at the end of the book
      --toc-title=VALUE      Name of the Table of Contents
      --author=VALUE         Author name.
      --title=VALUE          Book title.
  -v, --verbose              Turn on verbose output
  -i                         Convert <PRE class='image'> tages to PNG images
      --overwrite            Overwrite files without any prompt

Example:
         "ngen.exe -all -q "//h1" -q "//h2[@class='toc']" source.xhtml"
This expression will parse the xhtml file source.xhtml looking for the tag h1 an
d the tag h2 with an attribute class set to 'toc'. It will then create the html
 Table of Contents, the NCX Global Navigation file and the OPF file using the it
ems found.

The difference between the Ubuntu Terminal and the WineConsole is, that you cannot use the TAB to fill in the filenames for you, and you have to refer to directories in your actual directory with a ./directory_name/ instead of using simply directory_name/ as in the Ubuntu Terminal.

To run the Windows Command Line Interface run wineconsole cmd
To run do this without opening the Windows Command Line Interface, just run the command through WineConsole, as if you were using the Windows CLI. This way it is possible to use the TAB to fill in filenames, which is a pleasure. The Windows CLI will be opened by WineConsole to run the command, and be closed when the running ends. If the user is prompted for keyboard input, the Windows CLI will stay open and wait for the user input.
~$ wineconsole ncxGen.0.2.6.exe -a -q "//h1" --author="Book Author Name" --title="Book Title" --toc-title="TOC Title" ./Test_Book/Book.html

This way NCX-generator can be integrated into bash scripts :)

Running a command like the above (with -a option) having a Book.html and a Cover.jpg to begin with, will create the following files in the file directory:
Book.ncx
Booktoc.html
Book.opf
Bookout.html


NOTE: if you name the cover image Cover.jpg, and put it in the same directory as the book HTML, it will be automatically recognized and included properly in the OPF file, when you run ncxGen. By specifying the --author and --title options too, you will not have to edit the OPF manually at all before building your book with KindleGen.
However, some UTF-8 characters are not properly recognized in ncxGen, so if you use i.e. Hungarian characters like ő or ű in the title, toc-title or author, you'd better check the OPF and correct it.

2015. február 15.

Installing MobiPocket Creator on Ubuntu

First of all, install the latest version of wine.
Seconds, set it to have a 32-bit Wine Prefix :
remove the current Wine settings directory:
sudo rm -r ~/.wine
and then create 32 bit prefix with this command:
WINEARCH=win32 WINEPREFIX=~/.wine winecfg 
Now for Mobipocket Creator to run properly, run this in terminal and follow any instructions:
winetricks ie6 vcrun2005
Apparently creating new mobi books work, but it pops up an error every time you do something. Just ignore these errors and build the book anyway.

UPDATE:
do this to have a clear GUI for Mobipocket Creator:
winetricks ie8
This solves the pop-up errors and the incomplete user interface!


Install MobiPocket Creator:
Download from official page,
double click to install with Wine.

Usage

Installing the latest version of Wine

I installed Wine from the repository, but it did not work well with the program I installed on it, so I tried out what happens if I update Wine.

1. add the wine source to your repository:
sudo add-apt-repository ppa:ubuntu-wine/ppa
2. update repository list:
sudo apt-get update
3. install latest version of wine
sudo apt-get install wine

The program I wanted to run, and were fixed by this update:
  • Amazon Kindle Previewer

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.