elros34 / sailfish_linux_chroot

GNU General Public License v3.0
20 stars 4 forks source link

Opening a XWayland window from command line in Ubu shell #7

Open Kabouik opened 4 years ago

Kabouik commented 4 years ago

Is it possible? Typically, I would be interested in running mpv URL in Ubu shell and see a mpv window open. There would be other use cases of course, libre LibreOffice or many other applications which would benefit from the full-screen real estate.

This is a naive question, I understand it might be complicated/impossible, but just asking in case there is a trick to do it easily.

elros34 commented 4 years ago

Sure, just like chromium is used but not every application would work correctly without window manager (matchbox is worth to try because it can be used in fullscreen mode), other would need some wayland compositor.
For apps started with x11 mode: ./ubu-start.sh qxcompositor, then Xwayland & and start appplication wayland: ./ubu-start.sh qxcompositor, then start application (for example 2048-qt)

It's all hacky and usually only x11 is usable. The best would be wayland compositor with xwayland suport. Kwin is probably the best candidate but for reason I mentioned in #5 I am not interested in. Another option is simple qtwayland compositor + xwayland. I made some tests about it but had a lot of touch and focus issues, I suspect due to old qtwayland in sailfish.

Kabouik commented 4 years ago

Thanks for your quick answer @elros34. So this should be possible, but not necessarily easy, and highly dependent in the applications. Actually I tried mpv wthin xfce4 and it does not work either:

[vo/gpu/wayland] Compositor doesn't support the required xdg_wm_base protocol!

Not a big deal, that was just one potential use.

I'm not sure how to start XWayland after qxcompositor and before the application as you described, I guess I could find some inspiration in the .desktop file for Chromium.

elros34 commented 4 years ago

To start xwayland just type "Xwayland &". I have added experimental option to start qxcompositor + xwayland + shell with one command in dev branch: ./ubu-start.sh xwayland [optional app to start]

Kabouik commented 4 years ago

Excellent, thanks. What would be the best way to get the new feature without erasing my current configuration? I suppose git pull would overwrite the files that changed when I configured Ubuntu.

elros34 commented 4 years ago

You can always 'git stash' your changes and 'git stash pop' to restore them latter.

Kabouik commented 4 years ago

Thanks. I can confirm devel-su ./ubu-start.sh xwayland [app] works with Libreoffice and VLC at least, although it's broken for VLC. For mpv, there was an other error probably related to an issue with my SFOS Pro¹ regarding video playback (works in some apps, not in others).

Due to issue #6, I might have to keep using XFCE4, at least for the time being, but your experimental option is a nice addition.

[Edit] By the way, I ended up cloning the dev branch into a new folder and just replacing the .ext4 file after creation with the one I had created previously in the folder corresponding to the master branch.

elros34 commented 4 years ago

You sailfish's video issues are not relevant here. Everything is done by cpu in xwayland. You can have libhybris based ui acceleration with wayland compositors and I guess you could use gst-omx together with wayland compositor to get video acceleration but only for gstreamer based applications.

BTW that gst-launch command from your issue will do nothing, use jolla-gallery or:

gst-launch-1.0 -v playbin video-sink=glimagesink uri=file:///

Kabouik commented 4 years ago

I must admit I have no idea on how to achieve that, any pointers on which command lines I would need?

Right now mpv throws this:

[user@ubu-chroot: /home]# mpv host-user/Videos/MEDIA/The\ First\ S01E03\ Cycles.mkv 
Playing: host-user/Videos/MEDIA/The First S01E03 Cycles.mkv
 (+) Video --vid=1 (*) (h264 1280x600 23.976fps)
 (+) Audio --aid=1 --alang=eng (*) 'Stereo' (aac 2ch 48000Hz)
 (+) Subs  --sid=1 'The First S01E03 Cycles.srt' (subrip) (external)
[vo/gpu/wayland] Compositor doesn't support the required xdg_wm_base protocol!
[vo/gpu/opengl] Suspected software renderer or indirect context.
Segmentation fault
[user@ubu-chroot: /home]# 

And vainfo:

[user@ubu-chroot: /home]# vainfo
libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/arm-linux-gnueabihf/dri/emgd_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

However, mpv should be able to play without hardware decoding anyway.

I added gpu-context=wayland in mpv.conf but it din't change anything, I suppose everything is a bit different when using chroot. I am aware it might be a question for mpv maintainers rather than you, and I'll ask eventually, but I am curious whether video playbac (sw or hw decoded) works on your end.

elros34 commented 4 years ago

I see little point in running video player in chroot so I never tried. I suggest you to start with simple gst-launch playbin (maybe some additional gstreamer software codecs are needed) and if it's usable then mpv.

Based on mpv output looks like it try to use wayland so better try to start it somehow in x11 mode and force it use software codecs (mpv --list-options). As I stated above, I might be wrong but afaik hw decoding is only possible with gst-omx so VA-API is not an option.

elros34 commented 4 years ago

I was able to get some video working with cvlc:

cvlc --no-audio -vv /media/sdcard/SD32G/big_buck_bunny_720p_30mb.mp4

Kabouik commented 4 years ago

Interesting, thanks. It is useable on the Pro¹, but just barely: some frames are being dropped quite frequently as you can see below:

I'll have to look into the hw decoding options you described. But to be honest, my priorities right now are #5 and #6, and as you noticed, my skills are fairly limited. :>

Kabouik commented 4 years ago

Is it possible to add arguments to apps started using the experimental dev feature devel-su ./ubu-start.sh xwayland [app-to-start]? When I add arguments after the app name, ubu-start.sh does not know that they are arguments for this app, so it fails and say --givenoption is unrecognized. Single quotes did not help.

elros34 commented 4 years ago

set -x will tell you straightaway whether arguments are passed or not (they should). dev branch is removed already and everything is merged to master.

Kabouik commented 4 years ago

I had set -x, it is what told me that the option is unrecognized:

[nemo@Sailfish sailfish_ubu_chroot-dev]$ devel-su ./ubu-start.sh xwayland tilix --maximizePassword:++ export ON_DEVICE=0++ ON_DEVICE=0++ '[' -f /etc/sailfish-release ']'++ ON_DEVICE=1+++ logname++ export HOST_USER=++ HOST_USER=++ '[' -z '' ']'+++ loginctl --no-legend list-users+++ awk '!/root/ {print $2}'+++ head -n1++ HOST_USER=nemo++ export HOST_HOME_DIR=/home/nemo++ HOST_HOME_DIR=/home/nemo+ eval set -x++ set -x+ '[' 3 -eq 0 ']'++ ubu_ssh_pid++ pgrep -u root -x -f '/usr/sbin/sshd -p 2228'+ '[' -z '' ']'++ whoami+ '[' root '!=' root ']'+ run_qxcompositor xwayland+ '[' xwayland == qxcompositor ']'+ '[' xwayland == xfce4 ']'+ '[' xwayland == chromium ']'+ '[' xwayland == chromium-browser ']'+ '[' xwayland == xwayland ']'+ '[' 1 == 1 ']'++ ubu_qxcompositor_pid++ pgrep -u nemo -f 'qxcompositor --wayland-socket-name ../../display/wayland-ubu-1'+ '[' -n '' ']'+ '[' '!' -f /run/display/wayland-ubu-1.lock ']'+ sleep 1+ ubu_host_user_exe 'invoker -s --type=silica-qt5 qxcompositor --wayland-socket-name ../../display/wayland-ubu-1 -u user -p 2228'++ whoami+ '[' root == root ']'+ su nemo -l -c 'invoker -s --type=silica-qt5 qxcompositor --wayland-socket-name ../../display/wayland-ubu-1 -u user -p 2228'Last login: Fri Jan 10 16:03:23 CET 2020invoker: Invoking execution: '/usr/bin/qxcompositor'+ '[' '!' -f /run/display/wayland-ubu-1.lock ']'+ '[' xwayland == qxcompositor ']'+ ./ubu-chroot.sh su user -l '/usr/share/ubu_chroot/start.sh xwayland' tilix --maximize++ export ON_DEVICE=0++ ON_DEVICE=0++ '[' -f /etc/sailfish-release ']'++ ON_DEVICE=1+++ logname++ export HOST_USER=++ HOST_USER=++ '[' -z '' ']'+++ loginctl --no-legend list-users+++ awk '!/root/ {print $2}'+++ head -n1++ HOST_USER=nemo++ export HOST_HOME_DIR=/home/nemo++ HOST_HOME_DIR=/home/nemo+ eval set -x++ set -x++ ubu_ssh_pid++ pgrep -u root -x -f '/usr/sbin/sshd -p 2228'+ '[' -z '' ']'++ whoami+ '[' root '!=' root ']'++ mount++ grep /.ubuntu++ wc -l+ MOUNTS=0+ '[' 0 -gt 5 ']'+ '[' 0 -gt 0 ']'+ ubu_mount_img+ mount -t ext4 -o loop,noatime ubuntu-19.04-armhf.ext4 /.ubuntu+ ubu_mount+ '[' '!' -d /.ubuntu ']'+ mount --bind /dev /.ubuntu/dev+ mount --bind -o mode=620 /dev/pts /.ubuntu/dev/pts+ mount --bind /dev/shm /.ubuntu/dev/shm+ mount --bind /sys /.ubuntu/sys+ mount --bind /proc /.ubuntu/proc+ mount --bind --make-slave --read-only / /.ubuntu/parentroot+ mount --bind --make-slave /home/nemo /.ubuntu/home/host-user+ mount --bind /tmp /.ubuntu/tmp+ '[' 1 == 1 ']'+ mount --bind /run/display /.ubuntu/run/display+ mount --bind --make-slave --read-only /system /.ubuntu/parentroot/system+ '[' 1 == 1 ']'+ '[' -d /.ubuntu/run/user/100000 ']'+ mkdir -p /.ubuntu/run/user/100000/pulse+ mount --bind /run/user/100000/pulse /.ubuntu/run/user/100000/pulse+ mount --bind /var/lib/dbus /.ubuntu/var/lib/dbus+ '[' -d /.ubuntu/home/user/.config/pulse ']'+ mount -o bind,ro /home/nemo/.config/pulse /.ubuntu/home/user/.config/pulse++ ls /run/media/nemo+ for dir in '$(ls /run/media/$HOST_USER)'+ mountpoint --quiet /run/media/nemo/_+ mkdir -p /.ubuntu/media/sdcard/_+ mount --bind --make-slave /run/media/nemo/_ /.ubuntu/media/sdcard/_+ _ubu_chroot su user -l /usr/share/ubu_chroot/start.sh xwayland tilix --maximize+ '[' 7 -gt 0 ']'+ ubu_chroot /usr/share/ubu_chroot/chroot.sh su user -l /usr/share/ubu_chroot/start.sh xwayland tilix --maximize++ readlink -f /etc/resolv.conf+ rsync -a /run/connman/resolv.conf /.ubuntu/etc/+ rsync -a scripts/chroot.sh scripts/create.sh scripts/install.sh scripts/start.sh /.ubuntu/usr/share/ubu_chroot/+ rsync -a ubu-variables.sh /.ubuntu/usr/share/ubu_chroot/+ chmod a+x /.ubuntu/usr/share/ubu_chroot/chroot.sh /.ubuntu/usr/share/ubu_chroot/create.sh /.ubuntu/usr/share/ubu_chroot/install.sh /.ubuntu/usr/share/ubu_chroot/start.sh /.ubuntu/usr/share/ubu_chroot/ubu-variables.sh+ rsync -a scripts/dotuburc /.ubuntu/home/user/.uburc++ hostname+ HOSTNAME=Sailfish+ grep -q Sailfish /.ubuntu/etc/hosts+ '[' '!' -f /home/nemo/.ssh/id_rsa.pub ']'++ cat /home/nemo/.ssh/id_rsa.pub+ grep -q 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDDtFTemt7f2mUvvVcDqyIrAlQ5yq0gRUA4h3oiF8qQf+S/2EbBCslsODmDi0q64cyhd8r83xtbd7nkdvQUPkZT9ekdfk2nqjAZ04GGmhrPNNs3xy5aJAnyvx4ITkfctpc+a+dUq2KaBv9yeNv9+lXSP0TjHMCxZAZXkxGInE/0acVTvDcb/qV5QgO4/7nYMHOMdrLj1DaA9jjdnOPEGht7ouXex59UNh9BbJERaEzMr9XeHR0NG6hl+otMErW2C2BM41tAhFFvo5psnl9V//ZojLJA2eYo2hBY0XND1nw7WXCV2bbS6PK1y7/7GHaNWnYy+8tfUsSJ98WRcZUfHHwGmYXJSd2YwudfRS2rOR45kqB3N4C3rBXcAjFm5veTwazb/gyseGIrffDhrXuZKdbL9+3PpaDsImlNyQ/lexMxFVAlzehB6qqMYvsA0i1mEN/L8rXtyI1gOEv2caiCDY9J7L4ftA5lA1QKCn/wz4DF5VWbMaGdHKw8siKNfW3O3U8= nemo@Sailfish' /.ubuntu/home/user/.ssh/authorized_keys++ stat -c '%a %G:%U' /.ubuntu+ '[' '755 root:root' '!=' '755 root:root' ']'+ '[' 1 == 1 ']'+ '[' '!' -f .screen_dimensions_set ']'+ '[' 1 == 1 ']'+ '[' 1 == 1 ']'+ '[' -d /.ubuntu/usr/share/X11/xkb ']'+ '[' '!' -f .xkeyboard_synced ']'+ print_info 'chrooting /.ubuntu'+ echo -e '\n\e[93m=== chrooting /.ubuntu ===\n\e[0m'=== chrooting /.ubuntu ===+ chroot /.ubuntu /usr/bin/env -i HOME=/root TERM=xterm 'PS1=[\u@ubu-chroot: \w]# ' PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games /bin/bash --login /usr/share/ubu_chroot/chroot.sh su user -l /usr/share/ubu_chroot/start.sh xwayland tilix --maximize+ '[' '!' -f /run/sshd.pid ']'+ /usr/sbin/sshd -p 2228+ '[' -d /parentroot/usr/libexec/droid-hybris/system/ ']'++ mount++ grep 'unionfs on /system'+ '[' -z '' ']'+ unionfs -o allow_other,nonempty /parentroot/usr/libexec/droid-hybris/system/:/parentroot/system/ /system+ su user -l /usr/share/ubu_chroot/start.sh xwayland tilix --maximizesu: unrecognized option '--maximize'Try 'su --help' for more information.[nemo@Sailfish sailfish_ubu_chroot-dev]$

Sorry, somehow copy/pasting from Fingerterm removes new lines.

Actually, it seems the script tries to apply the --maximize argument I wanted to su instead of tilix.

elros34 commented 4 years ago

Looks like I broke it lately, apply this: https://github.com/elros34/sailfish_ubu_chroot/commit/c4b6b30a8c15d3f78f54ef8545871045d4452f05 I really have problem to correctly handle arguments in bash...

Kabouik commented 4 years ago

Nice, thanks! It works well with Tilix, which is interesting on Pro1 because of the many actions that can be associated with keybindings, plus tiling and a sidebar toggle that is easy to tap onto. The only issue is Tilix has no --font-size argument to compensate for the unadapted dpi so I created another profile called Xwayland with bigger font size, and kept the default profile as default for use in xfce4.

Screenshot_20200110_001

/usr/share/applications/ubu-tilix.desktop:

[Desktop Entry]
Type=Application
Categories=Ubuntu;
X-Nemo-Application-Type=no-invoker
Icon=icon-launcher-shell
Exec=bash -c "cd /home/nemo/sailfish_ubu_chroot; ./desktop/ubu-exec.sh xwayland tilix --geometry=2160x1080 -p Xwayland"
Name=Ubu Tilix
# X-Nemo-Single-Instance is ignored by lipstick launcher, patch is needed
X-Nemo-Single-Instance=no
Terminal=false
Kabouik commented 4 years ago

Short update on video: or some reason, mpv --gpu-context=wayland now works (tested within xfce4 only so far), while it didn't before. I don't know what I installed since then, as I have been customizing my .ext4 file quite a lot. Of courses it still drops too many frames due to no hw decoding. Perhaps I could try installing libhybris.

Screenshot_20200112_002

However, with another file in 720p and h.264, it was actually quite efficient and dropped just a few hundred frames overall. Very usable with this file.

Kabouik commented 4 years ago

I suppose this could be closed now. However, perhaps you can add some documentation so users know that this is now possible now. Something like:

Just like you can start chromium-browser in its own standalone SFOS window without launching xfce4, it is now possible to do the same with other applications previously installed in the ext4 Ubuntu image (e.g., using sudo apt install ApplicationName in the terminal in Ubuntu launched with xfce4) using the following command as devel-su in the SFOS shell:

/path/to/sailfish_ubu_chroot//desktop/./ubu-exec.sh xwayland ApplicationName

Once confirmed to work properly from terminal, you can manually create a .desktop file in /usr/share/applications/ubu-ApplicationName.desktop` to add an icon in the SFOS launcher. Below is an example with Tilix:

[Desktop Entry]
Type=Application
Categories=Ubuntu;
X-Nemo-Application-Type=no-invoker
Icon=icon-launcher-shell
Exec=bash -c "cd /home/nemo/sailfish_ubu_chroot; ./desktop/ubu-exec.sh xwayland tilix --geometry=2160x1080 -p Xwayland"
Name=Ubu Tilix
# X-Nemo-Single-Instance is ignored by lipstick launcher, patch is needed
X-Nemo-Single-Instance=no
Terminal=false