[Updated: JUN 15] Easier XMir Setup (Now with Libertine!)

ShadowEO

Senior Member
Mar 15, 2012
489
133
63
28
Columbus, Ohio
EDIT: I bring you the new OFFICIAL way of installing X11 applications, I've been neglecting this thread way too much and need to give it some love.

The old instructions (OLD METHOD) are no longer needed as of April on the rc and rc-proposed channels, this should work on all channels however (tested up to latest devel-proposed image)

NOTE: You still need a writable image for the first parts of this, after you install the tools, it can go back to read-only.

1) Open Terminal
2) Install the following packages: libertine libertine-tools python3-libertine-chroot
3) Open the Ubuntu Store and install the scope: libertine-scope
4) Open the Libertine application that's now available in your launcher and follow instructions, it will set up a Ubuntu Vivid chroot in your home directory, install the components needed, and drop you at the package management screen. From here, you can update and add PPAs to the container via the Settings Icon -> Manage Container, Install packages via the plus icon, etc.
5) Favorite the Libertine XApps scope by swiping up on the home screen and hitting the star, then open the scope and you'll see any applications you installed there.

If you cannot install your container via the Libertine application (I know that it didn't have support for chroot until recently, not sure if that version has landed yet), you can install your container via the teminal, so open your terminal but DO NOT sudo su. All Libertine-container-manager commands MUST be done as phablet.

To create a container (this line will likely change when Xenial drops as Libertine will be switching to LXC on Xenial):
Code:
libertine-container-manager --create -i <container id> -n <friendly name (this shows up in the Libertine app)> -t chroot
Using this command, the system will build the new libertine container, wait until it's finished and then you can continue by using the installed Libertine application.

Onscreen Keyboard in Libertine Applications
THIS CAN FINALLY BE DONE! The only con to it, is that it is mostly unusable in applications that open dialog boxes along the bottom of the screen, the XMir window does not scroll up like native applications do to give a better viewing window. (I have been told that this will change in OTA-12 when the keyboard support drops for Libertine/Puritine apps)

To install on-screen keyboard:
Open Libertine and add ppa:brandontschaefer/maliit to your container. Then hit update in Manage Containers. Once done, install the following, maliit-inputcontext-gtk2, maliit-inputcontext-gtk3, maliit-framework. After that, setup is complete in your container, now we need to do some extra work outside the container to make it pass the GTK_IM_MODULE variable we need over to Libertine. To do this, add this line to your .bashrc or if you have a writable image, you can add this to the systemwide profile (not sure if this will be replaced on OTA though):

Code:
export GTK_IM_MODULE=maliitphablet
Restart the tablet OS, Open an application such as Libreoffice Writer and BEHOLD!

Notes
You can also manage your container via the terminal with libertine-container-manager. To get a root shell without installing mate terminal (You can't get a root shell via this method (installing a term), Proot acts like fakeroot all over your container's rootfs), you can use the following:
- l-c-m exec -c bash (This command does not mount any user directories (/home/phablet will not exist) and is best used for making changes to the container's rootfs)
or if you only need a user shell:
- DISPLAY= libertine-launch <containerid (default is vivid)> bash (This mounts user directories, but is no different than if you installed something like mate-terminal and ran it. The reason we are passing an empty DISPLAY variable is because libertine-launch will refuse to start if DISPLAY isn't set, even it if doesn't exist.)
- DPI Hacks: To change the DPI of applications in Libertine, you need a new way to make the .Xdefaults file as only the XDG User directories get mounted inside the libertine container, not your entire Home. To do this, install your favorite editor inside of the libertine container (I find nano to be the easiest for new users), and open Terminal, then follow these instructions:
1) Open your editor to ~/.local/share/libertine-container/user-data/[my container id, default = vivid]/.Xdefaults and fill it with the following:
Code:
Xft.dpi: 175
or what your preferred DPI is. On the Nexus 7 flo the comfortable DPI is 175 with an application font size of 14 (I use Liberation Sans which comes from Libreoffice).
- You can make your applications look great still, you don't have to be stuck with the default Raleigh GTK style. Download and install LXAppearance in your container and add ppa:noobslab/themes then start installing themes. Enjoy! The Ubuntu Touch Themes are wonderful and FlatPlat works well with the system UI as well.

Some cons to this:
- It requires at least 3GBs available in your internal storage (wherever your home folder resides) to store a full, non-touch Ubuntu Vivid container.

Pros:
- It survives OTAs, the only thing able to break this would be a change to XMir, PRoot, or Libertine. Which is landing in the images shortly by default so there's not much of a chance to break this.
- Nothing you do will break your UTouch system. Unlike the old method, this only installs the items needed to run the container, which are to become standard inside the images very soon.


OLD METHOD
--------------------
EDIT: I have not tested this in stable, rc, rc-proposed yet. Only the dev-proposed channel.

So there is some questioning I see going on about how to run things like Firefox efficiently and well. So I figured I'd write up a little something for it.

First you'll want to set your DPI in ~/.Xdefaults, as I have a Nexus 7, mine looks similar to this:
Xft.dpi: 240

Note that you may need to do some additional tweaking.
Now that you have Xdefaults made, install the ubuntu-pocket-desktop and matchbox-window-manager packages (along with the program you wish to use, for this tutorial, I'll use libreoffice).

Create a file in /bin called wm-wrapper.sh (or whatever you choose here, just remember the name), fill it with:
Code:
#!/bin/bash
matchbox-window-manager -use_titlebar no -use_dialog_mode const-horiz &
exec [email protected]
and save it, then chmod a+x it.

EDIT: For this next part, I recommend copying the .desktop to ~/.local/share/applications to avoid them being overwritten on package updates.
Now, navigate to /usr/share/applications/ and open the .desktop file for the application you are wanting to run. Add the following lines under [Desktop]:
Code:
X-Ubuntu-Touch=true
X-Ubuntu-XMir-Enable=true
Change the Exec line so that your wrapper (in my case wm-wrapper.sh) is in front of the executable, such that the line becomes (or similar):
Code:
Exec=/bin/wm-wrapper.sh libreoffice %U
Save it, then search for your application in the Unity Scopes. Open it up and you should see your application running as an XMir app easy. For future applications, you will simply need to do the changes to it's .desktop file.

EDIT: A helpful redditor gave me this tip to enable sending touch events over to Xmir. Setting the GTK_TEST_TOUCHSCREEN environment variable to 1 will apparently remove hover events and the like (events that are not normally sent with a touch screen, but with a mouse). I have not had time to take a look at this yet however so YMMV.
 
Last edited:

ShadowEO

Senior Member
Mar 15, 2012
489
133
63
28
Columbus, Ohio
Thanks man, gonna try this on my n4 later today.
No problem, Like I said, not sure if it works on other channels, but it works great on the dev-proposed channel. You will also want to close applications using their menu items as closing the Xmir root window will cause the application to terminate without asking to save anything. Libreoffice can get around this via Document Recovery though.

I had been working on this for a good solid week testing applications and different ways to get X11 applications working so I could make it a full workstation, so I figured why not post my findings since the Ubuntu forum doesn't seem to get much love.
 

doniks

Senior Member
Jul 15, 2014
70
11
28
Thanks for the matchbox tip! It works quite nicely, especially, it brings a nice onscreen keyboard with it. I use the following setup now:

  • ~/.local/share/applications/gedit-mb.desktop
    Code:
    [Desktop Entry]
    Name=GEdit in Matchbox
    Type=Application
    Terminal=false
    Icon=/usr/share/gedit/logo/gedit-logo.png
    X-Ubuntu-Touch=true
    #X-Ubuntu-XMir-Enable=true 
    Exec=/home/phablet/bin/matchbox-wrapper.sh gedit
  • ~/bin/matchbox-wrapper.sh
    Code:
    #!/bin/bash
    export DISPLAY=:1
    Xmir $DISPLAY &
    sleep 1
    # xlogo
    # xeyes
    # x11vnc -forever -nopw -quiet -display $DISPLAY &
    matchbox-window-manager &
    sleep 1
    matchbox-keyboard &
    [email protected]
  • ~/.matchbox/kbdconfig
    Code:
    # http://unix.stackexchange.com/questions/223110/what-are-the-keyboard-shortcuts-for-matchbox-window-manager
    <ctrl><alt>p=prev
    <ctrl><alt>n=next
    <ctrl><alt>d=!matchbox-desktop
    <ctrl><alt>x=!xterm
    <ctrl><alt>f=!firefox

Together with the Xft.dpi setting (I use 220) this gives me a quite usable editor. If you have any other tips ShadowEO, I'd love to hear them!
 

ShadowEO

Senior Member
Mar 15, 2012
489
133
63
28
Columbus, Ohio
Do you have a specific example? Which application are you looking at?
Sorry, for some reason I wasn't subscribed to this post (weird.)

Anyway the specific application I was looking at was gedit, when started with the native GDK Mir backend, it is almost unusable with touch as the elements are so small. GDK_SCALE doesn't work and neither does any of the GTK dconf settings for scaling.

Also, I have switched to using rc-proposed, so any more changes I do will likely be able to be installed without worrying about the snapshot channel.

Also messing with some touch-screen specific .gtk2.0-rc entries seem to help, but since I reformatted, I don't quite have those offhand at the moment. I'll have to look them up again.
 
Last edited:

takri

New member
Apr 5, 2016
2
0
0
Hi!
Thanks a lot for all these useful explanations! Finally I was able to run Firefox on my bq E4.5 (rc-proposed)! But I have a few questions:
1) I don't have any on-screen keyboard
2) it works like with a mouse (no touch scrolling for instance)
Is there something I can do about that?
 

ShadowEO

Senior Member
Mar 15, 2012
489
133
63
28
Columbus, Ohio
Hi!
Thanks a lot for all these useful explanations! Finally I was able to run Firefox on my bq E4.5 (rc-proposed)! But I have a few questions:
1) I don't have any on-screen keyboard
2) it works like with a mouse (no touch scrolling for instance)
Is there something I can do about that?
You could try the touchegg package for multi touch gestures, I haven't gotten around to testing it yet. As for keyboard, you can use onboard for most applications or if the application is a QT application, it will pop up the system keyboard (behavior was exhibited by calibre)
 

takri

New member
Apr 5, 2016
2
0
0
You could try the touchegg package for multi touch gestures, I haven't gotten around to testing it yet. As for keyboard, you can use onboard for most applications or if the application is a QT application, it will pop up the system keyboard (behavior was exhibited by calibre)
Thanks a lot for your answer. Sorry I don't know much yet about all this so my questions might be silly!
1) I installed touchegg but I don't know how to make it work
2) I have no keyboard in any app I installed (caja, gedit, firefox, ...)

Another question: I have a bq E4.5 and although I have 3.5G of free space on my internal memory the space available for apt-get-ed apps is much smaller (I have 50M left after installing just those few apps above). So no way to try libreoffice or other heavier app. Do you know if there is a solution for that?

Thank you very much!
 

doniks

Senior Member
Jul 15, 2014
70
11
28
2) I have no keyboard in any app I installed (caja, gedit, firefox, ...)
If you use the matchbox setup I described above then you should have a keyboard.

Another question: I have a bq E4.5 and although I have 3.5G of free space on my internal memory the space available for apt-get-ed apps is much smaller (I have 50M left after installing just those few apps above). So no way to try libreoffice or other heavier app. Do you know if there is a solution for that?
This website describes a tweak to put the apt cache on an external SD card. It's in German, but the command lines should be clear enough. Let us know how it goes.
https://wiki.ubuntuusers.de/Ubuntu_Touch/Terminal/#Freien-Speicher-beobachten
 

ShadowEO

Senior Member
Mar 15, 2012
489
133
63
28
Columbus, Ohio
You would need to run touchegg in the wrapper. Sadly wth keyboard, the only applications that will get the system keyboard are QT based applications. GTK+ and other applications will require onboard to be installed. I messed around with trying to install maliit-context-gtk2 to get the system keyboard to show in all apps, but that broke the keyboard completely.

Remember XMir is better used with a physical keyboard since it doesn't trigger the Ubuntu keyboard for everything.

You can also make the system img bigger if using MultiROM: you simply run e2fsck -fp /path/to/Ubuntu.IMG and resize2fs <target size> /path/to/Ubuntu.IMG.
 
  • Like
Reactions: rbradley274

doniks

Senior Member
Jul 15, 2014
70
11
28
You would need to run touchegg in the wrapper.
I've played around with this a bit, but I can't get touchegg to work. I start an xmir application, then log in via ssh from my desktop. After setting the DISPLAY variable, I can start more X applications ok. After starting touchegg I see an output like this:

Code:
Reading config from  "/home/phablet/.config/touchegg/touchegg.conf" 
Try to make a multitouch gesture. If everything goes well the information about the gesture must appear 
[+] Avaliable gesture: 
         Name ->  Flick 
[+] Avaliable gesture: 
         Name ->  Drag 
[+] Avaliable gesture: 
         Name ->  Pinch 
[+] Avaliable gesture: 
         Name ->  Rotate 
[+] Avaliable gesture: 
         Name ->  Tap 
[+] Avaliable gesture: 
         Name ->  Touch
I assume that I am supposed to see some more output when a touch gesture is recognised by touchegg, but nothing ever shows up.

I can see touch events with either xinput or evtest

Code:
$ xinput test "xmir-fake-touch-pointer:0"
motion a[0]=36317 a[1]=42290 
button press   1 
motion a[0]=36590 a[1]=41730 
motion a[0]=36645 a[1]=41275 
motion a[0]=36536 a[1]=40469 
motion a[0]=36263 a[1]=39524 
motion a[0]=35935 a[1]=39034 
motion a[0]=34897 a[1]=38019 
motion a[0]=33532 a[1]=36934 
motion a[0]=32713 a[1]=36303 
motion a[0]=31839 a[1]=35778 
motion a[0]=31293 a[1]=35533 
motion a[0]=30856 a[1]=35323 
motion a[0]=30638 a[1]=35253 
motion a[0]=30419 a[1]=35148 
motion a[0]=30255 a[1]=35078 
motion a[0]=29928 a[1]=34903 
motion a[0]=29873 a[1]=34868 
motion a[0]=29873 a[1]=34868 
motion a[0]=29873 a[1]=34868 
button release 1
Code:
$ evtest /dev/input/event0
Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "elan-touchscreen"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
  Event type 3 (EV_ABS)
    Event code 47 (ABS_MT_SLOT)
      Value      0
      Min        0
      Max        9
    Event code 48 (ABS_MT_TOUCH_MAJOR)
      Value      0
      Min        0
      Max       31
    Event code 53 (ABS_MT_POSITION_X)
      Value      0
      Min        0
      Max     1343
    Event code 54 (ABS_MT_POSITION_Y)
      Value      0
      Min        0
      Max     2239
    Event code 57 (ABS_MT_TRACKING_ID)
      Value      0
      Min        0
      Max    65535
    Event code 58 (ABS_MT_PRESSURE)
      Value      0
      Min        0
      Max      255
Properties:
  Property type 1 (INPUT_PROP_DIRECT)
Testing ... (interrupt to exit)
Event: time 9936.473027, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 1159
Event: time 9936.473088, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 12
Event: time 9936.473088, type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 27
Event: time 9936.473118, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 338
Event: time 9936.473118, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1059
Event: time 9936.473149, -------------- SYN_REPORT ------------
Event: time 9936.509709, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 11
Event: time 9936.509709, type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 43
Event: time 9936.509709, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 351
Event: time 9936.509739, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1061
Event: time 9936.509739, -------------- SYN_REPORT ------------
Event: time 9936.512791, type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 46
Event: time 9936.512791, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 357
Event: time 9936.512791, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1063
Some websites point to synclient for the configuration of touchegg, but that doesn't seem to work in Xmir:

Code:
$ synclient 
Couldn't find synaptics properties. No synaptics driver loaded?
Does anyone else have more luck with touchegg?

While researching it, I stumbled over references to xSwipe, but I haven't looked into that any further.

You would need to run touchegg in the wrapper. Sadly wth keyboard, the only applications that will get the system keyboard are QT based applications. GTK+ and other applications will require onboard to be installed. I messed around with trying to install maliit-context-gtk2 to get the system keyboard to show in all apps, but that broke the keyboard completely.

Just to reiterate, the matchbox-keyboard works fine for me!
 

ShadowEO

Senior Member
Mar 15, 2012
489
133
63
28
Columbus, Ohio
I completely forgot the matchbox keyboard while writing that reply, I'm not sure what's going on with touchegg as I haven't had a chance to play with it on Ubuntu touch. It could be that XMir isn't actually passing that much information about touch events.
 

eskizon

New member
Oct 19, 2013
2
1
0
matchbox-window-manager struggle

I am on the new Aquarius m10 Ubuntu tablet.

Tried to run tome applications and realized the X11 and Mir problem.

Came across your solution! Thank you for sharring!

Well, I dont seem to be able to install matchbox-window-manager
It shows a lot of missing dependencies and I am not abble to install them manually either.. :(

The following packages have unmet dependencies:
matchbox-window-manager : Depends: libmatchbox1 (>= 1.7-1) but it is not going to be installed
Depends: libstartup-notification0 (>= 0.2) but it is not going to be installed
Depends: libxsettings-client0 but it is not going to be installed

Any light?? Thank you very much
 

doniks

Senior Member
Jul 15, 2014
70
11
28
I am on the new Aquarius m10 Ubuntu tablet.

Tried to run tome applications and realized the X11 and Mir problem.

Came across your solution! Thank you for sharring!

Well, I dont seem to be able to install matchbox-window-manager
It shows a lot of missing dependencies and I am not abble to install them manually either.. :(

The following packages have unmet dependencies:
matchbox-window-manager : Depends: libmatchbox1 (>= 1.7-1) but it is not going to be installed
Depends: libstartup-notification0 (>= 0.2) but it is not going to be installed
Depends: libxsettings-client0 but it is not going to be installed

Any light?? Thank you very much
Mhm, not sure. You do have set it to read-write and you did an apt update, right?
 

Tazard4

New member
May 31, 2009
3
0
0
Mhm, not sure. You do have set it to read-write and you did an apt update, right?
Thanks for sharing this info! I also own the M10 ubuntu tablet and try to run some X11 apps.
I am able to apt-get matchbox-window-manager. But it won't start and says it can't find the display.
Running either:
Code:
matchbox-window-manager
matchbox-window-manager -d :0
as a normal user or root always returns: "can't open display! check your DISPLAY variable.".

ubuntu-pocket-desktop is up to date and I also set the DPI in ~/.Xdefaults.

What could be the reason it can't find the display? What could I try?
 

ShadowEO

Senior Member
Mar 15, 2012
489
133
63
28
Columbus, Ohio
Bumping this thread as I've edited the OP with the official instructions for running Legacy X Applications on Ubuntu Touch. As well as information about getting the system maliit-based OSK showing in X Applications (It's not that great though, you still may have better luck with matchbox-keyboard/on-board, but not sure how you'd even start those in Libertine.)
 
  • Like
Reactions: doniks