Showing posts with label e17. Show all posts
Showing posts with label e17. Show all posts

Sunday, March 6, 2016

xdg-open arcanery

In the midst of playing with tycat and terminology on a virtual console*, it became apparent that xdg-open wasn't doing its job in regards to opening PDF documents.

  bash# xdg-open /tmp/dw.pdf 
  Filename "file:///tmp/dw.pdf" does not exist or is not a regular file

A simple check of the default handler shows that everything is fine:
  bash# xdg-mime query default application/pdf
  evince.desktop
..but for fun, let's try to change it and see what happens.
  bash# xdg-mime default apvlv.desktop application/pdf
  bash# xdg-open /tmp/dw.pdf 
  Filename "file:///tmp/dw.pdf" does not exist or is not a regular file
Nothing.

Grepping for the error in /usr/bin/xdg-open comes up empty. It's odd that two unrelated programs (evince and apvlv) would have the incorrect error message (the file does exist and is regular), or that they would both fail to handle file:// URIs. How does xdg-open actually route these requests?

Turns out it depends on your window manager. If you are running Enlightenment, xdg-open performs the following:

open_enlightenment()
{
    enlightenment_open "$1"

    if [ $? -eq 0 ]; then
        exit_success
    else
        exit_failure_operation_failed
    fi
}

Replacing enlightenment_open "$1" with open_generic "$1" works. Can we invoke open_generic when enlightenment_open fails? Turns out we can't, because enlightenment_open returns 0 (success) even when the file isn't opened.

Fixing enlightenment_open might do the trick. The relevant code (enlightenment.git/ src/bin/e_open.c) is here:

        char **itr;
        int ret = EXIT_SUCCESS;

        for (itr = cmds; *itr != NULL; itr++)
          {
             /* Question: should we execute them in parallel? */
             int r = system(*itr);
             if (r < 0)
               fprintf(stderr, "ERROR: %s executing %s\n", strerror(errno),
                       *itr);
             free(*itr);
             if (r > 0) /* Question: should we stop the loop on first faiure? */
               ret = r;
          }
        free(cmds);

        return ret;

It turns out that the status of what enlightenment_open is calling is ignored. But what is it calling? Adding the line fprintf(stderr, "Trying %s\n", *itr); after the system() call uncovers what is actually happening:

bash# make src/bin/enlightenment_open
  CC       src/bin/src_bin_enlightenment_open-e_open.o
  CCLD     src/bin/enlightenment_open
bash# src/bin/enlightenment_open /tmp/dw.pdf 
Filename "file:///tmp/dw.pdf" does not exist or is not a regular file
TRYING evince-previewer 'file:///tmp/dw.pdf

Where the hell did evince-previewer come from? To make a long story short, xdg-open (and enlightenment_open, and all other *_open tools) uses /usr/bin/mimeopen as a backend. 

This utility operates on files, not mime-types:

bash# mimeopen -a /tmp/dw.pdf 
Please choose an application

1) Print Preview  (evince-previewer)
2) Document Viewer  (evince)
3) vprerex  (vprerex)
4) GNU Image Manipulation Program  (gimp)

use application #
Cancelled

OK, so that is where evince-previewer is coming from. A quick test shows that the actual bug is caused by evince-previewer not understanding file URIs:

bash# evince-previewer file:///tmp/dw.pdf
Filename "file:///tmp/dw.pdf" does not exist or is not a regular file
bash# evince file:///tmp/dw.pdf
(evince:21480): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -82 and height 15

That Gtk warning accompanies evince loading and displaying the file just fine. 

Changing the handler for PDFs using mimeopen turns out to work just fine:

bash# mimeopen -d /tmp/dw.pdf 
Please choose a default application for files of type application/pdf

1) Print Preview  (evince-previewer)
2) Document Viewer  (evince)
3) vprerex  (vprerex)
4) GNU Image Manipulation Program  (gimp)
5) Other...

use application #2
Opening "/tmp/dw.pdf" with Document Viewer  (application/pdf)

(evince:21510): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -82 and height 15
bash#  xdg-open /tmp/dw.pdf 

(evince:21550): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -82 and height 15
xdg-open /tmp/a.pdf

(evince:21602): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -82 and height 1

Of course, that doesn't mean that evince-previewer is the only bug. Since evince-previewer returns 1 (failure), enlightenment_open should be returning 1 instead of 0:

        int ret = EXIT_FAILURE;

        for (itr = cmds; *itr != NULL; itr++)
          {
             int r = system(*itr);
             if (r < 0)
               fprintf(stderr, "ERROR: %s executing %s\n", strerror(errno),
                       *itr);
             free(*itr);
             ret =  r;
          }

...and xdg-open should check the return value and fallback to open_generic:

    enlightenment_open "$1"

    if [ $? -eq 0 ]; then
        exit_success
    else
        open_generic "$1"
        if [ $? -eq 0 ]; then
            exit_success
        else 
            exit_failure_operation_failed
        fi
    fi

Let's not even get started on why xdg-open doesn't propagate changes back to mimeopen. Wait, why doesn't it?

UPDATE: looks like there's something deeply wrong with with the xdg-* utilities:

bash# xdg-settings get default-web-browser
xdg-settings: unknown desktop environment

The problem here is that xdg-settings performs its own check for desktop environment (modularity, people!) and, of course, implements this poorly. If the desktop environment is detected (as is Enlightenment), but is not KDE|Gnome|XFCE|MATE,  it returns "unknown desktop environment". If the environment is not detected, a generic handler is called. There are some very confused people working on this software.

The fix is to modify xdg-settings, changing the default case statement
*)
    exit_failure_operation_impossible "unknown desktop environment"
    ;;

to

*)
    dispatch_specific generic "$@"
    ;;

* For those interested: install tslib and rebuild EFL from source, then run the following on a virtual terminal:
ELM_ENGINE=fb /usr/local/bin/terminology -f=nexus/20
Yes, the -b option for a backgroud image will work, as will tytls, tyop, and tycat.

Sunday, July 31, 2011

Easy E(17)

Ubuntu finally ships with a working E17, but there is a lingering problem: most of the modules are gone!

To get a full-featured install of E17, replete with modules and UI enhancements (finally! the settings panel entries re available from the main menu!), it is best to install from SVN.

Building E17 has always been an ordeal. Fortunately, the script easy_e17.sh makes downloading, building, and installing E17 from SVN to be quite a simple affair, once all of the dependencies are met.


To begin with, download the easy_e17 script from http://omicron.homeip.net.

There is a bug in the script which must be fixed if packages are going to be built. According to this bug report, the line (around 36 or 37)

  packages_full="$efl_basic $bin_basic $e_modules_bin $e_modules_extra $efl_extra
$bin_extra"


should be

  packages_full="$efl_basic $bin_basic $e_modules_bin $efl_extra $bin_extra $e_modules_extra"


... in order to get all the internal dependencies straight. Failure to do this results in the following error:
e_mod_main.c:1527:32: error: ‘ethumb_client’ undeclared (first use in this function)


Next, install all necessary dependencies to build E17 and the modules:

bash$ sudo apt-get install autopoint libudev-dev libgcrypt11 libgcrypt11-dev
bash$ sudo apt-get install libasound2-dev libasound2 libxine-dev 
bash$ sudo apt-get install paman padevchooser paprefs pavucontrol pavumeter 
bash$ sudo apt-get install libiptcdata-dev libmpd-dev cython libxcb-shape0-dev

According to this guide, the full list of dependencies is as follows:

bash$ sudo apt-get install xterm make gcc bison flex subversion cvs automake1.10 autoconf autotools-dev autoconf-archive libtool gettext libpam0g-dev libfreetype6-dev libpng12-dev zlib1g-dev libjpeg62-dev libtiff4-dev libungif4-dev librsvg2-dev libx11-dev libxcursor-dev libxrender-dev libxrandr-dev libxfixes-dev libxdamage-dev libxcomposite-dev libxss-dev libxp-dev libxext-dev libxinerama-dev libxft-dev libxfont-dev libxi-dev libxv-dev libxkbfile-dev libxres-dev libxtst-dev libltdl7-dev libglu1-xorg-dev libglut3-dev xserver-xephyr libdbus-1-dev liblua5.1-0-dev libasound2-dev libudev-dev autopoint  libxml2-dev

Chances are, however, that most of these are already installed.


The E17 build makes some assumptions about the location of the gcrypt libraries, so they must be symlinked:

bash$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgcrypt.a /lib/x86_64-linux-gnu
bash$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgcrypt.la /lib/x86_64-linux-gnu
bash$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgcrypt.so /lib/x86_64-linux-gnu

...other wise linker errors such as the following will appear:
../../src/lib/.libs/libeet.so: undefined reference to `gcry_cipher_setiv'
../../src/lib/.libs/libeet.so: undefined reference to `gcry_cipher_setkey'


The Xine development headers (libxine-dev) must be installed in order for emotion to compile; otherwise an error like this will appear:
configure: error: Xine, Gstreamer or VLC backends must be selected to build Emotion
Naturally, Gstreamer or VLC headers could be installed instead.


The asound2-dev and the pulseaudio tools are required to get the mixer module working. Without them, the error
No ALSA mixer found!
will appear in the mixer module settings. Note that pulseaudio requires that the current user be added to the audio group; this can be done with the following command:

  sudo adduser $USERNAME audio



Once all this is done, it is a simple matter to install E17 with the following command:

./easy_e17.sh --instpath=/usr/local/e17 --srcpath=/home/$USER/src/e17 -i

This downloads the E17 source code to ~/src/e17, and sets the install directory to /usr/local/e17. There should be a nice success message if everything goes well.

Next, build all of the modules:

./easy_e17.sh --instpath=/usr/local/e17 --srcpath=/home/$USER/src/e17 --packagelist=full -i



Upgrading is just as straightforward:

./easy_e17.sh --instpath=/usr/local/e17 --srcpath=/home/$USER/src/e17 --packagelist=full -u


Final notes:

  * The composite module causes problems: when using the Software engine, it causes typing delays that make terminals near unusable; when using the OpenGL engine, windows do not update until there is a focus change (BIG problem). It should be disabled.

  * The shelf containing the systray module must be given the stacking order Above Everything; otherwise, the applications in the E17 systray will not receive mouse clicks (VERY BAD).

  * Determining the fonts used by various modules is easier when the source is available. The font classes used in the tclock module, for example, are in E-MODULES-EXTRA/tclock/tclock.edc. The time is displayed in text_class: "module_large", and the date is displayed in text_class: "module_small". The Settings->Look->Fonts dialog can be used to determine the font used for these classes by enabling (via the checkbox at bottom-right) the font class Modules::Small or Modules::Large, and setting the font (e.g. Sans/Regular/12 pixels) to be used for each.

UPDATE : Recent builds now fail when using --packagelist=full. Best stick with --packagelist=half if the full build fails.

Saturday, May 30, 2009

Toshiba R500 Backlight Button

Keep forgetting to u/l this script for toggling the r500 backlight using toshset:

#!/bin/sh

TOSHSET=/usr/local/bin/toshset

STATE=`sudo $TOSHSET -trmode 2>/dev/null | grep -a transreflective | \
cut -f 3 -d ' '`

if [ $STATE = "on" ]
then
NEW_STATE="off"
else
NEW_STATE="on"
fi

sudo $TOSHSET -trmode $NEW_STATE


Xev shows the keycode for the backlight (and the 'i' internet/information/idiot key, so they'll both do the same thing) to be 180, which is already taken by XF86HomePage in Ubuntu. If for some reason this key is undefined (i.e. nothing shows up on `xmodmap -pke | grep '^keycode 180'`), add the following line to ~/.Xmodmap (which might need to be symlinked to ~/.xmodmaprc on non-Ubuntu Linuxes):

keycode 180 = XF86HomePage

In E17, edit the keyboard bindings using Settings-> Settings Panel -> Input -> Key Bindings. For XF86HomePage, select the Launch : Defined Command option, and point it to the above shell script (e.g. in ~/bin).

Note that the script uses sudo to launch toshset, so you will either need to change this to invoke an GUI sudo program like gtksu, or add a line like the following to /etc/sudoers:

$USER ALL=(root) NOPASSWD: /usr/local/bin/toshset

where $USER is your username. Note that this allows any toshset command to be run as root without a password from this user's session, which could be exploited if someone were sufficiently motivated.

Friday, March 6, 2009

Insipid Ibex

Finally upgraded (K)Ubuntu to 8.10. Thanks for breaking my xorg config, guys, by assuming that HAL could actually do a better job that my hand-picked settings. This is easily fixed by uncommenting all of the lines commented out by HAL, but it's amazing that it had to be done at all, since the HAL change made X flat-out stop working. Also, for some reason, ~/.xsession no longer works -- one has to use ~/.xsessionrc instead. Those wacky Ubuntites.

Upgraded E17 shortly afterwards, using the packages at

deb http://greenie.sk/ubuntu intrepid e17

The new version of E has compiz support (which has to almost entirely be disabled for it to run at E17's proper speed) and looks nice. The modules all seem to work, for once.

But it crashes!

The first one came immediately, and was fixed by wiping ~/.e, which contained all of my old config settings. Apparently E17 can't reliably be upgraded with an existing config. Thanks for moving to a binary config file, guys, so that this is actually a far larger problem than it should be. Really, how hard is it to use the binary config only at runtime, and compile from text to binary whenever a config change is made?

Some of the other crashes appear to be from the OpenGeu inclusion of compiz. After removing the calls to emerald and ecomorph from enlightenment_startup.sh, and stripping out the -evil command line option (which, along with -good and -psychotic, did not seem to make things stable), it's become pretty stable, if a little buggy. Dialog boxes occasionally do not disappear when closed, requiring a restart of E17.

Also, some E17 idiocies remain -- things that seemed to be oversights before, but now (having been a pretty stable WM for the past three years) appear to be truly asinine design decisions.

Specifically:

* There is no way to modify the properties of an application (short of adding it to iBar, or modifying the desktop file directly). A dialog exists for this (it's used by ibar and when creating a new application), so it can't be much extra work.

* One cannot cut/copy/paste between E17 widgets and X. This is nice to be able to do when, say, setting an icon file path (since the desktop files for KDE applications do not seem to be handled correctly by E17, and therefore have no icon files). Hope you like typing.

* The binary only config, mentioned above. Really, there is no excuse for this -- the rest of the industry learned that lesson in the 90s. Even Windows allows its abhorred registry to be read from and written to text files.

Aside from that, Ibex works well, and the upgrade was generally painless. The only sticky points were the Xorg conf file (their mistake), E17 (my fault for running it), and the patch I needed to add to get toshset supported by the latest kernel (the maintainer's fault, for not getting it merged after 2 years of reliable performance).

Wednesday, April 23, 2008

e17 profile backup script


Given that E17 uses binary config files, and these may get hosed without warning, it is useful to back them up after making changes.

The following shell script will do just that, via tar:

#!/bin/sh

[ -d ~/.e/backup ] || mkdir -p ~/.e/backup

tar -zcf ~/.e/backup/e17-config-$(date +%F-%T).tgz ~/.e/e


Also worth noting is an improved way of using the E17 profile switching for extending battery life: put a shell script for switching to the battery profile in /etc/acpi/battery.d, and one for switching to the A/C profile in /etc/acpi/ac.d . Note that this occasionally causes E17 to crash (and take X with it), so be conservative.

Current configuration:
  • Smoke theme, Darkness startup, Slick icons
  • 10 1x1 virtual desktops
  • XRENDER engine with Composite disabled
  • 3 profiles (AC, battery, and default)
  • Run command: uxterm -bg black -fg orange -fa 'xft:Courier New' -fs 11 -hold -e
  • Shelf (invisible, below windows, shrink:48, all desktops) on upper right-top (Contents: cpufreq, mixer, winselector, battery, deskshow, tclock, temperature, exalt)
  • Shelf (invisible, below windows, shrink:60, all desktops) on lower left-left (Contents: Pager)
  • Shelf (default, below everything, shrink:40, all desktops, auto-hide) on upper left-top (Contents: Start, IBar, Taskbar)
  • Shelf (invisible, above everything, shrink:40, all desktops, auto-hide) on lower right-bottom (C0ntents: IBox)
  • Shelf( default, above everything, shrink:48, desktop 0:0, auto-hide) on lower-right-right (Contents: News, Forecasts)

I should note that Forecasts doesn't seem to work at all. I also disabled the screen savers, lock, and power management as they are all a bit crashy.

The screenshot isn't much to look at.

Friday, March 21, 2008

xdg-open and general freedesktop annoyance

Using the E17 RSS reader has recently acquainted me with xdg-open from freedesktop.org, or as it is more affectionately known, "the utility that causes all URLs to be opened in the most sucky browser installed, e.g. konqeror or nautilus".

Fortunately, you can add the lines

BROWSER=`which firefox`
export BROWSER

into ~/.profile, or into ~/.bashrc and do the old bash-profile-symlink-hack:

ln -s ~/.bashrc ~/.bash_profile

...and a reasonably well-written XSession file (e.g. the one that ships with *buntu)
will find it.

But come on, an ENVIRONMENT VARIABLE? For a helper program called by X applications?
You have to restart X if you want to change it!

What is so horrible about an optional freedesktop config file, say in ~/.local/etc/defaults/browser, that lets you change this at runtime?

Or, if having to read a file every time a link is checked is the problem (I can see that), why not have a freedesktop config service that caches settings and can be flushed by the user?

There is an upside to all of this: having spent the past evening restarting either E17 or X to tweak parts of the system, I am coming to like the idea of using XSM to restore all of my terminal, IDE, and browser sessions. If it plays well with E17's virtual desktops.

Systrayless Wifi

Didn't come across this last time I was playing with E17: exalt network manager.

Install:

sudo apt-get install exalt exalt-daemon emodule-exalt libexalt-dbus-dev libexalt-dev


This solves the "have to run knetworkmanager in an alternate WM' problem, as
exalt runs as a standalone app (and has an E17 widget).

Caveats: Hold the shift key (not Caps Lock!) down when entering your WEP key, and be sure to changed the mode from Ad-Hoc to Managed.

For those who are suffering with unmaintained E17 packages, use the Gos servers:

deb http://packages.thinkgos.com/gos/ reloaded main
deb-src http://packages.thinkgos.com/gos/ reloaded main

Tuesday, November 13, 2007

E17 via edevelop.org

Enlightenment may have the most stable CVS (actually SVN) repository in the business, but their Debian packages (via Edevelop.org) just flat-out suck.

After upgrading from my initial, stable install, I experienced problems with E17 crashing when the network went up or down (which happens frequently on a laptop). I took the time to upgrade again and poof! No more E17.

Running it from the command line via xinit gives the following error:

/usr/bin/enlightenment: error while loading shared libraries: libecore_evas.so.1 : cannot open shared object file: No such file or directory


Doing dpkg shows that libecore_evas1 is installed (as is libecore_evas0), but the specified shared library doesn't exist.

A dpkg -l of libecore_evas0 and libecore_evas1 shows the problem:

bash# dpkg -L libecore_evas0
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libecore0-evas
/usr/share/doc/libecore0-evas/README
/usr/share/doc/libecore0-evas/AUTHORS
/usr/share/doc/libecore0-evas/copyright
/usr/share/doc/libecore0-evas/changelog.gz
/usr/share/doc/libecore0-evas/changelog.Debian.gz
/usr/lib
/usr/lib/libecore_evas.so.0.9.9
/usr/lib/libecore_evas.so.0

bash# dpkg -L libecore_evas1
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libecore1-evas
/usr/share/doc/libecore1-evas/README
/usr/share/doc/libecore1-evas/AUTHORS
/usr/share/doc/libecore1-evas/copyright
/usr/share/doc/libecore1-evas/changelog.gz
/usr/share/doc/libecore1-evas/changelog.Debian.gz


Someone forgot to include the .so in the package! Good going, guys.

Wednesday, October 17, 2007

E17 profiles

I finally got around to playing with E17 profiles, which are located under the 'Advanced' section of the Configuration Panel. I kinda figured that, the E guys being who they are, I could use these to toggle between CPU-eating animated backgrounds/icons and normal static backgrounds when the laptop is running on battery or A/C power. I was right!

I put the following script in /usr/local/bin/e17_switch_profile.sh :
#!/usr/bin/env bash

# Switch e17 profile based on arg1

# 1. Check if E17 is running
if [ `ps ax | grep enlightenment | grep -v 'grep' | wc -l` -eq 0 ]
then
# no enlightenment running
exit 0
fi

# 2. Make sure E_IPC_SOCKET is set
if [ -z "$E_IPC_SOCKET" ]
then
# we are called from outside of e17
E_IPC_SOCKET=`ls -a /tmp/enlightenment-*/disp-*`
if [ -z "$E_IPC_SOCKET" ]
then
# something wrong with enlightenment!
echo "Cannot set E_IPC_SOCKET!" >> /dev/stderr
exit 0
fi
E_IPC_SOCKET=${E_IPC_SOCKET%|*}
fi

# 3. Get username to switch to
if [ $# -gt 0 ]
then
profile="$1"
else
# switch to default
profile="default"
fi

# 4. Switch enlightenment user!
E_IPC_SOCKET="$E_IPC_SOCKET" enlightenment_remote -default-profile-set $profile
This has the usage `e17_switch_profile.sh profile_name`, with 'default' being used when no profile name is provided.

I then modified /etc/acpi/power.sh as follows:

function laptop_mode_enable {
# Local Changes ---------------------------
/usr/local/bin/e17_profile_switch.sh battery
telinit 4
# -----------------------------------------

$LAPTOP_MODE start
# <...DETAILS OMITTED...>
}

function laptop_mode_disable {
# <...DETAILS OMITTED...>
$LAPTOP_MODE stop

# Local Changes ---------------------------
telinit 2
/usr/local/bin/e17_profile_switch.sh ac
# -----------------------------------------
}
There are three changes from the Ubuntu default:
  1. LAPTOP_MODE is enabled (see /etc/laptop_mode/laptop_mode.conf )
  2. The battery runlevel is 4, while the A/C runlevel is 2 (the default)
  3. The e17_profile_switch is called to set the profile to either 'battery' or 'ac'
Obviously the remaining step is to create those two profiles in E17, and set them up accordingly.

The runlevel trick is one I've been using for awhile: I modify one of the existing runlevels to kill off unnecessary daemons, and optionally to run shell scripts (placed in init.d of course) to do things like change the hard drive spin-down time or the CPU frequency governor. Note that laptop-mode-tools provides this latter capability, so my current battery runlevel just kills off services that aren't that important:
bash# ls -1 /etc/rc4.d
K19cupsys
K20apport
K20dirmngr
K20hplip
K20ntop
K20privoxy
K20pulseaudio
K20rsync
K20ssh
K20stunnel4
K20tor
K20udftools
K25bluetooth
K30mpd
K89anacron
K89atd
K89cron
K99avahi
K99dbus
K99networking
Some of these may seem strange choices, but I tend to not use the net when on battery (usually I'm holed up at a coffee shop coding), and likewise I avoid resource-intensive applications (Open Office, KDE, multimedia, etc). If I really want to stretch the battery life I'll kill X, but Acroread and Firefox are a bit useful for consulting documentation.