Wrapped in gaffa

Programming, Art, Music, Philosophy, Politics

Posts Tagged ‘Linux

Configuring Debian Squeeze with PolicyKit for sudo

with 7 comments

I’ve recently gone back to the roots and installed Debian testing to replace Ubuntu. I would like to keep the concept of a disabled root account from Ubuntu, I tried for a long time using trial and error until I Read The Fucking Man page and found the solution to configure PolicyKit for sudo users. I’ve chosen to use a new group I called admin like the one from Ubuntu, although using the sudo group would fit the purpose on my single user machine.

As usual:
su root
adduser <username> sudo

With visudo make sure you have a line like this:
%sudo ALL=(ALL) ALL

Expire the root password and set sudo mode in gnome:
sudo passwd -l root
gconftool --type bool --set /apps/gksu/sudo-mode true

Create the group admin and join it:
addgroup admin
adduser <username> admin

Edit /etc/polkit-1/localauthority.conf.d/50-localauthority.conf:

Change this:

To this:

This setup is the one I’ve chosen, with disabled root and a permissive sudo group. There is endless possibilities if you read the man pages of sudoers and pklocalauthority.

That’s it! I hope…

Ari had a an important comment to make:

That configuration file says not to edit it. Just copy the file to something like 90-customauthority.conf with the same customized contents.


Written by gaffa

2009-11-05 at 19:05

Posted in Debian, Gnome, Linux, Software, Ubuntu

Tagged with , , , , ,

Update Anjuta Auto-Complete

leave a comment »

The tags used by the auto-complete feature (Scintilla only) in Anjuta can be updated by running this script:


The script automatically scans your /usr/include folder. It is also running pkg-config to update dependencies for packages.

Maybe there is a way to do this from within Anjuta, but if if there is, it is so unintuitive that it was more obvious for me to open a terminal and write dpkg -L anjuta-common to locate a script ;)

I’m having some issues with the Devhelp extension for Anjuta on Ubuntu 7.10, I’ll post something if I find some time to debug it. I know it crashes on running gtk_moz_embed_realize, but I don’t know why yet ;)

Written by gaffa

2007-12-29 at 02:18

Battle for Wesnoth

with 4 comments

Graphics (5/10):
Good looking 2D graphics.

Sound (5/10):
The music is great, but I get the feeling it isn’t synced to support the gameplay. The fighting sound effects are good, but that is all the sound effects there is. No audio in dialogs.

Gameplay (8/10):
8! 8!? Yes, 8. At first the game looked like something I would throw away before I even completed the first level, but as I began to think of the turnbased gameplay as a boardgame/puzzle I got addicted. Who doesn’t like puzzles? The rules are simple, but that is what makes it great. It is not an RPG you get lost in. You have a castle where you can recruit players with your main character. You can take over houses to get more money and your characters get 8 healthpoints if they skip a turn staying in a house. Your characters have experience points and can be promoted when they get enough experience. You can use the environment to your advantage. You can hide in a forrest or fight an enemy standing in water. The evil races increase their chances of a good hit by 25% by night and yours are down 25%. The rules are pretty simple, and I like the simplicity. I’m not much into RPGs because you have to devote so much time to learning and understanding them. Battle of Wesnoth is simple and great!

Community (10/10):
The team behind Battle for Wesnoth has brilliantly included the users in the making of the game. It is easy to modify the game and all you need to know is one click away on Wesnoth.org. Wesnoth.org also has a great forum, where users gather to create art, music/sound, translations and maps with peer reviewing. This project has the spirit of Free Software.

Overall (8/10):
You might not agree, but luckily I’m the one who decides which games are great and which games are not. I can guarantee that this game is a top scorer and that 8/10 wont be topped in the next couple of games I review. As a plus it works on Linux, Windows and MacOSX. I couldn’t connect to the official internet server as the version in Ubuntu Edgy repositories is older than the server version, but I doubt multiplayer would have changed my rating of this game.

Go grab it!

Written by gaffa

2007-01-25 at 22:19

Posted in Games

Tagged with , , ,

Trash on portable devices

leave a comment »

Experienced users know that Ubuntu (Gnome) creates a trash folder on removable devices so they use Shift+Delete to permanently delete data. Rookie users don’t care that there is a folder and empties the trash can.

There is a bug report in Ubuntu that says Shouldn’t put .Trash-$USER on removable devices and there is a bugreport in Nautilus that says Ask to empty when unmounting media with items in trash. I think both titles are a sign that this is not a bug, but a matter of intuitive behaviour.

If we chose to have a concept of trash cans that is what we should stick with. Inconsistent behaviour is not user friendly. That said it might be convenient to have an option to always permanently delete files or automatically empty the trash can before unmount on certain devices.

I came across an actual bug when I was looking at the default behaviour. It seems like the trash applet is not updating when I delete something on a portable device. That should be be fixed.

Trash is rediscovered when the device is remounted, which is more than I expected when I read the bug reports.

Inconvenience #1
I can not empty individual trash folders. I have to empty all my trash.
Solution: Is obvious isn’t it?

Inconvenience #2
The folder is left on the device even when empty. If many different users use the same device. It would end up looking like this:
This happens on a FAT formatted device which lack a concept of users.
I could also imagine that some devices can’t handle directories prefixed with “.” and that is another good reason to delete the trash folder on portable devices when it is empty.
Solution: Trash folder on portable devices should be deleted when empty.

Feature #1
Option to empty trash before unmount with Yes/No dialog.

I don’t like permanent deletion as an option, when you can always delete with Shift+Delete or just enable the option in Nautilus and use the Right-click menu.

What is your thoughts?

Written by gaffa

2007-01-22 at 00:48

Posted in Gnome

Tagged with , , ,

GtkNotebook Ramblings

The idea of tabs can be thought of as a stack of bricks. If you count the bricks from the bottom to the top and pull a brick out. The index of the new brick will be the same as the old. Top of the stack excluded. Notebook tabs should be the same and almost is in GtkNotebook.

Think of tabs in a notebook as a double linked-list namely GList.
typedef struct {
gpointer data;
GList *next;
GList *prev;
} GList;

Where data is a pointer to a GtkNotebookPage. When a page is removed you just update the next/prev pointers in the tabs around it – and we have a nice stack of bricks.
struct _GtkNotebookPage
GtkWidget *child;
GtkWidget *tab_label;
GtkWidget *menu_label;
GtkWidget *last_focus_child; /* Last descendant of the page that had focus */
guint default_menu : 1; /* If true, we create the menu label ourself */
guint default_tab : 1; /* If true, we create the tab label ourself */
guint expand : 1;
guint fill : 1;
guint pack : 1;
guint reorderable : 1;
guint detachable : 1;
GtkRequisition requisition;
GtkAllocation allocation;
gulong mnemonic_activate_signal;
gulong notify_visible_handler;

The programmer using the API knows the tabs by index and calls the function gtk_notebook_remove_page which translate the index to a list element and passes it on to gtk_container_remove which emits a signal “remove”. The remove signal is caught by gtk_notebook_remove which calls gtk_notebook_real_remove

gtk_notebook_real_remove is called with a GList* list (a double linked-list of GtkNotebookPages) and a GtkNotebook* notebook.

This snippet find the new page in the GList. It gets the previous page unless the current page is the first tab.
next_list = gtk_notebook_search_page (notebook, list, STEP_PREV, TRUE);
if (!next_list)
next_list = gtk_notebook_search_page (notebook, list, STEP_NEXT, TRUE);

If we delete tab1 this would happen.

tab deleted old
Why not select Tab 1? Wouldn’t that be the natural thing to do if tabs are left aligned?

tab deleted new

It can be done by simply switching the order of STEP_PREV and STEP_NEXT
next_list = gtk_notebook_search_page (notebook, list, STEP_NEXT, TRUE);
if (!next_list)
next_list = gtk_notebook_search_page (notebook, list, STEP_PREV, TRUE);

Additionally #131920 causes the switch_page signal to report wrong index numbers as the signal is generated before the deleted page element is unlinked from the GList.

This can be fixed by simply calling g_list_remove_link as soon as we are done with the next/prev pointers of the list element and before signals are being sent. The element can still be used as usual until it is freed later.

I’m restriced in which file formats I can upload so here is how the patch looks like (against 2.10.6):
--- gtk+-2.10.6/gtk/gtknotebook.c 2006-09-10 08:33:15.000000000 +0200
+++ gtknotebook.c 2007-01-20 22:16:17.000000000 +0100
@@ -4148,9 +4148,11 @@
priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
destroying = GTK_OBJECT_FLAGS (notebook) & GTK_IN_DESTRUCTION;
- next_list = gtk_notebook_search_page (notebook, list, STEP_PREV, TRUE);
+ next_list = gtk_notebook_search_page (notebook, list, STEP_NEXT, TRUE);
if (!next_list)
- next_list = gtk_notebook_search_page (notebook, list, STEP_NEXT, TRUE);
+ next_list = gtk_notebook_search_page (notebook, list, STEP_PREV, TRUE);
+ notebook->children = g_list_remove_link (notebook->children, list);
if (notebook->cur_page == list->data)
@@ -4187,7 +4189,6 @@
if (!page->default_menu)
g_object_unref (page->menu_label);
- notebook->children = g_list_remove_link (notebook->children, list);
g_list_free (list);
if (page->last_focus_child)

Seems like my patch has been comitted in Gtk+ 2.13.3:

2008-06-08 Björn Lindqvist

Bug 131920 – gtkNotebook sends incorrect switch_page value

* gtk/gtknotebook.c (gtk_notebook_real_remove): Make switch-page
signal send correct page index when page index 0 is active and
removed. (#131920, Samuel Fogh)

Written by gaffa

2007-01-21 at 19:24

Posted in Gtk

Tagged with , , , ,