Archive

Archive for the ‘english’ Category

Automatic Screen Detection And Configuration Under Awesome WM

January 10th, 2012 No comments

Recently I’m mainly interested in automating my day-to-day tasks on Linux laptop. I’ve started with automating back-up process, now come time to automate external screen detection (and configuration).

For couple of months I was struggling with ZSH history to find XRandR commands that enables and disables external screen. During that time I was almost sure that there is another way of handling this task … since eg. Gnome was doing it automatically. First idea was to find part of Gnome that is responsible for this feature and simply just integrate it with Aersome WM. But my from-time-to-time raw searches didn’t snow any interesting resources. Therefore I’ve decided that I must done it by my self … this is how screenful project was born.

What is screenful ?

It is simple extension to Awesome WM that allows you (with little knowledge of Lua and XRandR params) automatically configure connected screen. It integrates udev drm/change event with Awesome and XRandR. First of all there is udev rule that when drm/change event appears inform screenful about output change in particular card. Then screenful will “calculate” which card output was connected/disconnected, computes screen id based on EDID and finally run configured action. When configuration file doesn’t have specified configuration for this id then screenles will append commented configuration for it and run default action.

What is unique in screenful ?

Same as Awesome WM config file, the screenful config file is a Lua script! Therefore you can do anything you can imagine when external monitor is connected/disconnected. For example you can switch mplayer default audio output when you HD TV set is connected using HDMI cable then change it back when you disconnecting HDMI cable. Also you can reorganize yours tags and windows using Awesome Lua API … and more … Honestly I doubt that you can achieve similar behaviour in any different Window Manager ;)

Project is hosted on github if you encounter any issues or have ideas about new functionalities in screenful feel free to fork me, fill a bug or mail me ;)

Automatic backup in Linux

December 29th, 2011 2 comments

Some time ago I’ve started backing up my laptop hard drive in any case of failure. Until today I was simply connecting external back-up-drive and manually launching mount && rsync command from zsh history. But this requires that always after connecting this special device I need to go to terminal, log in as root then find this back up command and run it.

Recently I was wondering how this process could be improved or even done automatically. I had few requirements:

  • it should be fully automated
  • system should inform me that back up process was started and that it ends
  • this notification should be done as some system pop up in X windows

So I’ve come with a solution that connects udev, DBus notification and awesome wm naughty library … and it is really simple ;)

How it works ? When you connects back-up-device udev will pick up this event, create a symbolic link to /dev/backup, then launch backup script. This script will send a notification through DBus, this event will be received by naughty and displayed as a simple notification in Awesome WM. After sending notification signal the backup script will mount given device and launch rsync command. After successful synchronization backup device will be unmonted and another notification signal will be send to inform you that you can now disconnect it.

How to achieve this ?

First of all we need to figure out UUID of our back up device (I assume that /dev/sdb2 is yours back-up-partition) :

# blkid /dev/sdb2
/dev/sdb2: UUID="97377fed-edaf-407b-9e02-5c6cecd6dceb" SEC_TYPE="ext2" TYPE="ext3"

Then we need to create new udev rule in /etc/udev/rules.d we can call it 99-backup.rules:

ENV{ID_FS_UUID}=="97377fed-edaf-407b-9e02-5c6cecd6dceb", SYMLINK+="backup"
ACTION=="add", ENV{ID_FS_UUID}=="97377fed-edaf-407b-9e02-5c6cecd6dceb", RUN+="backup"

Of course you need to replace my UUID with one you get from blkid command. Those two lines are responsible for creating symbolic link called backup in /dev directory to device with given UUID; second line will launch backup script when device with given UUID is added.

Finally we need to create our backup script and put it into /lib/udev directory. Here is content of this script:

#!/bin/sh
 
### CONFIGURATION ###
USER="lock"
MSG_TIMEOUT=-1
 
### DO NOT MODIFY ###
function show_notification() {
	su $USER -c "export DISPLAY=':0.0'; \
		export XAUTHORITY='/home/$USER/.Xauthority'; \
		/usr/bin/dbus-send --type=method_call --dest=org.freedesktop.Notifications \
			/org/freedesktop/Notifications  org.freedesktop.Notifications.Notify string:'' \
			uint32:0 string:'' string:'$1' string:'' array:string:'' array:string:'' int32:$MSG_TIMEOUT"
}
 
function backup() {
	show_notification "Backup process started! Do NOT disconnect backup device."
	mount /dev/backup /mnt/backup
	ionice -c 3 rsync -az --delete --exclude=/dev --exclude=/mnt --exclude=/media --exclude=/run --exclude=/proc --exclude=/tmp --exclude=/sys --exclude=/var/log --exclude=/var/run / /mnt/backup
	umount /mnt/backup
	show_notification "Backup process successed! You can disconnect backup device."
}
 
backup &

In this file you only need to change USER variable to yours UNIX user name, also you can adjust MSG_TIMEOUT to your needs (-1 means that default value will be taken). Most difficult part in this script was to figure out how to send DBus notification from root to regular user, since all window managers create and listen on theirs own session scoped buses. As you can notice we can force dbus-send command to send signal to proper bus instance by executing this command on behalf of  given user and with exported DISPLAY and XAUTHORITY variables.

Full source code is available on github. Have a nice and pleasant back up’s ;)

EGit Iteractive Adding

October 5th, 2011 5 comments

So what is “interactive adding” in git? Imagine situation when you change two or three lines in file (this could be also two or three blocks/methods), then you realize that you will want to commit those changes in two (three or more) separate commits.

Here is Al Blue’s description how interactive adding works in native git: Git Tip of the Week: Interactive Adding

What about EGit? Honestly this is currently supported … but it isn’t really straight forward to access. You need to select a file then choose from context menu Team > Compare With > Git Index and then you can easily move changes around, finally when you are happy with both versions (left is working tree and right is one that will be staged/added to index) just save compare editor contents. Version from right hand side will be added to index as it is in this editor.

OK, so now you can easily stage and unstage partial changes … maybe you would also like to partial replace staged changes by version in HEAD? Currently in version 1.1 you can compare version from git index with HEAD version using context menu Team > Compare With > Git Index with HEAD, but you cannot overwrite anything … yet, because (hopefully) in 1.2 such option will be available. Here is patch that adds this functionality (to be honest this is a side effect…).

And what about (my favorite) Synchronize View? Unfortunately EGit 1.1 don’t allow to move any changes in compare editors launched from Synchronize View … but with change mentioned above and with this one both features would be available from Git Commits model (before it was named as Git Change Set model)

Here is a short screen cast that shows how this work:

 

End of Google Summer of Code 2011

August 24th, 2011 No comments

Officially coding period in Google Summer of Code was closed last Monday (August 22nd) , so this is good time to sum up last three months of my work on EGit project.

During that time I’ve manage to contribute 32 commits (29 of them are already merged into master, rest is pending for review). I have also two not finished changes in my local git repository. First is about supporting non-workspace files in Workspace presentation model in sync-view, second is refactoring of current Git Change Set implementation.

Here is detailed list of things that was done during GSoC and are available in current nightly build:

  • improved synchronize wizard
  • Workspace presentation model will refresh after repository change
  • pushing from sync view to multiple repositories is now possible
  • Git Change Set presentation model will be refreshed after workspace change
  • context menu in synchronize view was cleaned up and git actions are shown for multiple selections
  • synchronization on folder level is now possible and it will narrow results just for selected folder (when synchronization is launched for project then results will show changes in whole repository)
  • local changes can be drag and dropped between <working tree> and <staged changes> nodes in Git Change Set presentation model

Performance improvements for Workspace presentation model are still awaiting for review in Gerrit. Some part of performance and memory usage improvements for Git Change Set are also pending in Gerri, I’m currently working on rest of required refactoring in Git Change Set presentation model.

I want to thank my mentor Matthias Sohn for his commitment in GSoC, for reviewing my patches and his feedback. It was a great pleasure working  with him! ;)

Progress on non-workspace files in Workspace presentation model

August 16th, 2011 2 comments

For last three weeks I was working on including non-workspace files in Workspace presentation model in Synchronize View. This idea can sounds weird since the Workspace presentation model was designed to show only changed files that are in Eclipse workspace … but there are some use cases in which such behavior seams to be reasonable (eg. EGit and JGit projects doesn’t import repository root into workspace only projects are imported and files like master pom.xml, README, LICENCE and so on are left outside workspace).

If you don’t import all data into Eclipse workspace you won’t see any incoming nor outgoing changes. Even more, after merge/rebase actions changes in non-workspace files will magically appear in those resources and can even brake something (eg. massed up in master pom.xml file).

So, what is current status ? First of all I want to point that I’m describing here current situation in my working copy, described here changes currently are not available in public. After hours of debugging, code analysis and rewriting my code I’ve manage to show some indication in synchornize view that there are some non-workspace chagnes. The next step will be to show what particular file was changed and then enable all operations like overwrite, mark as merged, etc.

Here is a screenshot showing current status:

Non-workspace files in Workspace presenation model
As you can see there is home folder in sync results. It even have expand indicator (but after expanding it there is nothing inside). I suppose that on windows this folder will correspond to drive letter, but I’m not sure here.  Now I only need to tell Team Framework that there are some files inside home node …

This seams to be quite easy task, since parent folder is already included in view … but this isn’t that easy. First of all Workspace model is based on IResource‘s with are manageable by Eclipse platform. Of course I can create such resource using IWorkspaceRoot.getFolder() and IWorkspaceRoot.getFile(). Unfortunately non-workspace resources created by those two methods will return theirs first segment (on unix system it will be usually /home) as theirs project. Of course such project doesn’t exist in workspace therefore this node is empty.

Honestly speaking I currently don’t have any good ides how to move things forward … as usually I’ll dive into debugging and code analysis …

Any hints and ideas from the community are kindly welcome!

Android workshops in Szczecin

July 23rd, 2011 1 comment

Recently we have huge moments in Java oriented area in Szczecin. W had JDK7 launch party … and now we (as a Szczecin Java User Group) are organizing all day long Android workshops. More information you can found on our mailing list and registration page.

Huge performance boost for EGit sync-view

July 18th, 2011 3 comments

For last few days I was working on EGit Synchronize View performance, especially on Workspace presentation model (the Git Change Set is next on my list ;) ). My starting point was 1m 40s to compare two linux kernel versions, v2.6.36 versus v2.6.38-rc2. Such result seams to be very good, but you need to know that it was achived on SSD hard drive and comparing to regular HDD it would be much worst (maybe more then 3 or 4 minutes).

What can be improved ? Fist of all, current implementation whenever it is asked for members of particular folder it opens repository* and read data directly from it. Of course there is a cashing mechanism, but it is only on single resource level. Therefore when you are launching synchronization on repository that have about 300 folders, current implementation will create and configure 300 connections* to repository to read data and then will cache it.

So, my idea was to create only one connection*, read all data at once and put them into global cache. This cache will be used whenever any list of members for given folder will be required. This approach gives about 2.5x performance boost to synchronization (from 1m 40s down to 40s). This result looks much better and maybe on HDD this action will take less then 2 minutes … but this isn’t over ;)

Reading members of folder is one thing, but getting information about particular file (it is changed, added or removed and does this change is incoming, outgoing or conflicting) is another. Currently we are reusing default implementation of SyncInfo class from Team Framework. This is really good implementation … when you cannot obtain such information from version control system. In Git  we have SHA-1 for each file and folder version and we didn’t have to compare file contents to check they are similar or not, comparing SHA-1 is sufficient. This should save lots of CPU time, disk IO’s and developer time waiting for synchronization to finish ;) .

Now when I already have cache that contains list of all changed resources it was natural thing to add information about change type to it. Then whenever Team Framework need to know change type it can be easily obtained from this cache … no IO’s are needed, no comparison just read from in-memory-cache and return proper value.

I’m sure that you are wondering how fast synchronization can be now … I can only that it is REALLY fast … as you can remember my stating point was 1m 40s, now same comparison will finish in less than 7s!! This means that now synchronization will be 14 times faster then before! What this means for a regular user? Well, it meas that you will get results of ‘Synchronize Workspace‘ action almost instantly.

Unfortunately, mentioned above changes are sill awaiting for review in gerrit, you can grab them from change #3891 and build it locally. I hope this will be included in 1.1 release …

* jgit uses concept of walks (with filters) through repository, but I’ve used more commonly recognized terminology here

Java7 Launch Party @Szczecin

July 15th, 2011 No comments

Java7 T-Shirt frontJava7 T-Shirt backSzczecin Java User Group is organizing a Launch Party event for JDK7. There would be a short introduction of new features in Java lanuage and API’s presented by Filip ‘Filus’ Pająk. Filip will be also speaking about Java7 syntax support in popular IDE’s like InteliJ Idea and Eclipse IDE.

As usually on ours meeting there would be drawing of licenses for JRebel and InteliJ Idea. This time we have also cool Java7 T-Shirts for all attendees.

Registration isn’t required but it would be nice if you can join this event on facebook (here you can also find mode details about this event).

Eclipse DemoCamp Poznan 2011

May 27th, 2011 2 comments

Same as year ago, I’ll be presenting some new features in Eclipse on DemoCamp Poznan.

This time I’ll be mainly speaking about code review and how this process can be handled from Eclipse. Everything will be based on Gerrit Code review, I’ll also show Gerrit Jenkins/Hudson integration by Gerrit Trigger, another used project will be mylyn-reviews and last but not least will be (of course) EGit. All those projects will be mixed up together to give an quick overview of Code Review 2.0

If you are interested in, please “register” on event wiki page.

See you in Poznan!

 


 

 

Here you can find my presentation slides.

EGit Synchronize View Workflow Updates

May 15th, 2011 15 comments

One part of my Google Summer of Code project is to improve EGit Synchronization workflow and make it easier for new user to understood how it works.

So almost two weeks ago I’ve write a post with proposed new workflow for Synchronize Wizard. The main idea of that post was to initialize discussion with community how they want to use this wizard. According to Google Analytics this post was displayed around 120 times with isn’t that bad I think … but only one person leave a comment on it with isn’t a good result. Maybe I’m doing something wrong or I’m not making myself clear enough. Or maybe this topic isn’t so important for other people … I don’t know, maybe you can help me and give me some hints?

Apart from this, here is another part of changes that are proposed to be done in Synchronize workflow. Most of them are waiting for comments and approval in gerrit. This a good moment for comments and share thoughts about current implementation, before it will be merged into master branch. Additionally I’ve opened two bugs for discussion on Synchronize Wizard and Team menu based workflows:

  • 344891 – for Team context menu
  • 344888 – for sync-wizard

I’m understood that you don’t want to play with our code base and struggle with project setup only to check one of two new features, so here is a short description of my ideas and some screenshots:

  1. Always use current selected branch (HEAD) as source of synchronization
    As you may know currently the synchronization-dialog (this is a dialog that pops up after you select Team > Synchronize… from project’s context menu) allows select source and destination branch, and after that you can launch the synchronization action.When I was implementing this feature I had in mind git diff command, where you can easily compare two given points in repository history. But this command produces a patch-like output. You cannot move changes around, the only action that you can do with it is to only review it. In case of Synchronize View we use to use it to move changes around and prepare commit. So it is more then simple git diff.

    Another huge issue with this approach is that handling Synchronize View context menu actions like ‘Commit‘, ‘Merge‘, ‘Overwrite and Update‘ gets really complicated when base branch isn’t actual working branch.

    Because of that I’ve decided that in new workflow you need to select only a destination branch! For now I think that I’ll not remove this functionality from EGit code, because maybe in feature we’ll found a use case when comparing two given branches without switching on one of them could be use full.

  2. Always fetch changes before synchronization
    I’ve spotted that new git users that comes from CVS or SVN doesn’t really get the idea of ‘fetching changes locally’. They launch synchronization and want to see incoming changes without fetching them into repository. This feature could be also useful for old git users, because it will save couple of mouse clicks ;) The implementation that I’ve proposed don’t launch fetch action all the time. It checks does current branch tracks any remote branch, if yes it fetches changes from that remote, otherwise it will not do anything.

    OK, but what when I’m off-line and I’m working on branch that tracks origin/master, I would be forced to wait until connection timeout occurs?

    Well … it depends ;) Every time fetch fails you will be informed by dialog that you can disable automatic-fetch in Team > Git preferences. So in the worst case you will wait only once for connection timeout, then you will be informed that you can disable auto-fetch.

  3. New Synchronize Wizard
    After discussion in bug 344888 I’ve decided to abandon changes that I’ve presented two weeks ago. And implement it this way:EGit Synchronize Wizard

    As you can see there is only destination branch. Also all project names have decorations that describes repository name and current branch name. There i a single button for include local changes and that’s all, no more pages and logic’s.

    Additionally, the Destination branch list will contain also additional refs like FETCH_HEAD

  4. New context menu option ‘Synchronize Workspace’

    EGit Synchronize Workspace

    This a short cut for comparing HEAD against HEAD with included locally made changes. It is useful when you want to see what changes you made in workspace before you commit them. I think that this is a most use case for synchronize view therefore I’ve decided to add this shortcut.

  5. No more Synchronize-dialog
    This a Matthias Sohn idea to replace synchronize-dialog with dynamically build sub menu entry (same as in ‘Switch To‘ action).

    EGit Synchronize... Sum Menu

    This sub menu will contain 20 elements at most. They are alphabetically ordered and include local and remote branches, tags and additional refs like FETCH_HEAD. You don’t find here HEAD and name of current selected branch, because for synchronizing against those is ‘Synchronize Workspace‘ action. If you don’t see branch or tag that you would like to synchronize against, you need to choose ‘Custom…‘ option. After that the Synchronize Wizard will be shown where you can choose destination from complete list of branches, tags and additional refs.

  6. Push and Pull actions in Synchronize View toolbar
     

    EGit SynchronizeView Push and Pull Toolbat Actions

    This change is merged into current master, so if you want to check out that you need to install a nightly build of EGit.

    There is only one limitation for push action, it works only when you are synchronizing one repository. It would be disabled when you synchronizing more then one repo.

It is all for now. Any ideas and comments are welcome (and needed ;) )!.