Search This Blog

Tuesday, December 28, 2021

Custom keyboard layout in Wayland

Unfortunately, the configuration at the and of this post does not work for Wayland Qt applications, like konsole, kate. A colleage from KDE Brazil telegram channel pointed me to a working solution.

Update 28/12/2021: the configuration below works for X11/XWayland applications only.

Going forward with migrating to Wayland. There are several smalls things to fix in my setup, one of them is adding a custom layout to workaround the fact that my child broken the Up key of my laptop's keyboard. I had mapped F9 to Up using $HOME/.Xmodmap, which does not work in Wayland. I have figure out how to that in Wayland [1] [2] and maybe this can help other people.

Create this file to configure XDG_CONFIG_HOME variable:

# /etc/profile.d/xdg.sh
export XDG_CONFIG_HOME=$HOME/.config

Create the $HOME/.config/xkb/rules/evdev.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">

<xkbConfigRegistry version="1.1">

  <layoutList>

    <layout>

      <configItem>

        <name>lvs</name> <!-- Change to any name you want -->

        <shortDescription>Layout LVS</shortDescription> <!-- Same here -->

        <description>Layout com F8, F9 e F10 remapeadas</description> <!-- Any description you want -->

        <countryList>

          <iso3166Id>US</iso3166Id> <!-- Add your country to this list -->

          <iso3166Id>BR</iso3166Id> <!-- My country: Brazil -->

        </countryList>

        <languageList>

          <iso639Id>eng</iso639Id> <!-- Layout language -->

          <iso639Id>por</iso639Id> <!-- Brazilian Portuguese -->

        </languageList>

      </configItem>

    </layout>

  </layoutList>

</xkbConfigRegistry>


Create a file $HOME/.config/xkb/symbols/lvs (the file name have to match the layout name in evdev.xml) with the actual changes you need. I just copied the file with the symbols I wanted to change to save time:

cp /usr/share/X11/xkb/symbols/srvr_ctrl $HOME/.config/xkb/symbols/lvs

Then I removed all lines that should not be changed. The final file is the following (the actual changes are in bold):

partial function_keys

xkb_symbols "fkey2vt" {

    key <FK08> {

        type="CTRL+ALT",

        symbols[Group1]= [ Prior, F8, F8, F8, XF86_Switch_VT_8 ]

    };

    key <FK09> {

        type="CTRL+ALT",

        symbols[Group1]= [ Up, Prior, F9, F9, XF86_Switch_VT_9 ]

    };

};

Comparing all this to the .Xmodmap it seems way more complicated :-( This is my .Xmodmap:

! 74 = F8 

keycode 74 = Prior                                            

! 75 = F9                                  
keycode 75 = Up Prior

You need to restart startplasma-wayland so the changes take affect. The best part is that it also works with X11, so I removed my .Xmodmap.

PS: the Up key does not work in konsole to show the previous command when running in wayland, even with an external keyboard with a physical Up key. That works in X11.

Saturday, December 25, 2021

Nvidia optimus with wayland. Help needed.

I have given a try on wayland and it works in my notebook (Gigabyte p34v5) when using only the Intel gpu (/dev/dri/card0) and mesa. Now I have been trying to make it work with the Nvidia gpu (GeForce GTX 970M, /dev/dri/card1) using proprietary driver. The thing about that gpu is that is uses optimus and thus need the following command to work with X11:

# /usr/share/sddm/scripts/Xsetup file
xrandr --setprovideroutputsource modesetting NVIDIA-0

There is just a blank screen on sddm whithout that command (the Nvidia gpu is not physically connected to the display, it needs the Intel gpu to send image to any display, the command above connects the Nvidia gpu to the Intel one). Since xrandr does not work with wayland I am kind of stuck trying figure out the equivalent of that command for wayland. I have tried the following environment variable to no avail:

WLR_DRM_DEVICES=card1:card0

My current startwayland.sh script is:

# card0: intel
# card1: nvidia
export WLR_DRM_DEVICES=card1:card0
export KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0
export XDG_RUNTIME_DIR=/tmp/1001
export XDG_SESSION_TYPE=wayland
export QT_QPA_PLATFORM=wayland
export GBM_BACKEND=nvidia-drm
export __EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/10_nvidia.json:/usr/share/glvnd/egl_vendor.d/50_mesa.json
export EGL_PLATFORM=wayland
export EGL_LOG_LEVEL=debug
export QT_LOGGING_RULES="kwin*=true"
export KWIN_GL_DEBUG=1
export WAYLAND_DEBUG=1
unset DISPLAY
mkdir -m 0700 -p $XDG_RUNTIME_DIR

if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then
    export $(dbus-launch)
    sleep 1
fi


kwin_wayland --xwayland --exit-with-session=konsole 2>&1 | tee -a kwin_wayland_log.txt

I am using kwin_wayland instead of plasma-wayland so less programs are started during my tests.

EGL is correctly initialized on both gpu by what can be seen on kwin_wayland_log.txt, though nvidia-drivers uses version 1.5 and mesa uses version 1.4.

The first relevant error is "kwin_wayland_drm: swapping buffers failed on output KWin::DrmOutput(0x559b35fd8d30, name="eDP-1", geometry=QRect(0,0 1920x1080), scale=1)". eDP-1 is my laptop's LCD and W2486 is an external monitor.

There is no screen update after I launch kwin_wayland similar to what happens with X11 without the xrandr command. I need to log through ssh to 'chvt' to a different virtual terminal or kill kwin_wayland to use laptop again. I guess I just need to instruct kwin_wayland to connect the output of nvidia gpu to intel's one to make everything work. I just do not know how to do that.

My environment:

x11-drivers/nvidia-drivers-495.46-r10:0/495 to use Nvidia's new GBM support instead of EGLStream
gui-libs/egl-wayland-1.1.9:0
gui-libs/eglexternalplatform-1.1:0
media-libs/mesa-21.3.2:0
dev-qt/qtwayland-5.15.2-r16:5/5.15.2 with patch Don't block in QWaylandDisplay::flushRequests
kde-plasma/kwin-9999:5 this is a git build of commit 445946382379b65701259bc1f75c92227348db31 from Dec 15 2021 so I can use platforms/drm: use gbm with NVidia driver 495+.

Have someone successfully run plasma-wayland with nvidia's optimus and gbm instead of EGLStream?

Sunday, June 5, 2016

LaKademy 2016

This year we celebrated the fourth LaKademy conference and for my luck it happened in the city I live in, Rio de Janeiro :-) The reason for that is because I have not had much time for contributing to KDE as I used to have. The fact that the event happened in Rio saved me a lot o time and sure I wouldn't miss it for nothing hehe.

The event lasted three and half days (the last day was an Sunday) and was also an opportunity to meet old friends like Tomaz:


and new friends like Fernando:



I have been talking to Fernando through Internet for almost one year and have never had the chance to meet him in person, though we live in the same city hehe. Hopefully, he will become one more contributor to KDE :-)

One of the things I did during the event was helping Lays developing the new QML user interface for brprint3d and giving some tips for her GSoC work in Umbrello:


And having fun :-)


Besides helping Lays, I also helped Ronny to investigate and fix a bug in this QML game and did some bug triage for Plasma NM and Solid. The end result was some old bugs closed and this patch to Qt Declarative to fix a crash that affects Plasma NM.

Actually, the crash is an assert being triggered in QList while VDMModelDelegateDataType::notify() iterates through a QList of QQmlDelegateModelItem pointers. Somehow the list size shrinks inside the loop and the index-out-of-range assert is triggered. While investigating the bug I noticed that QQmlDelegateModel::_q_itemsRemoved() iterated through the same list but did not trigger the assert. Looking into its source code there is this comment above a couple of lines of code:

// layout change triggered by removal of a previous item might have
// already invalidated this item in d->m_cache and deleted it

Applying the same code to VDMModelDelegateDataType::notify() prevents the assert being triggered. I submitted a review request for Qt Declarative 5.6 with my patch and I am waiting for the comments about it.

It was great to meet my KDE fellows, old and new faces, during this LaKademy. Hope to see them again during Akademy in September.

Saturday, August 1, 2015

Akademy 2015

Spain is a very nice place to visit. After the two Solid Sprints in Madrid and Akademy 2013, now it was time to visit A Coruna.

My trip to A Coruna started in July 22 from Rio de Janeiro city, where I live, to São Paulo city. While I was waiting for the flight in Rio de Janeiro I feared it would be cancelled because of the bad weather. The flight right before mine in the schedule was cancelled, then I became more apprehensive. After one hour of delay they announced the new boarding time and I reached São Paulo with plenty of time to take the flight to Madrid and from there to A Coruna.

Going to the hostel by bus was easier than I had thought. I was also lucky enough to take the Rialta bus in the second part of the trip from the airport to the hostel :-)

For me, Akademy started with attending KDE e.V General Assembly. About five hours discussing current KDE situation and what could we do to improve it. After the assembly we went back to the Rialta hostel for the first party during Akademy :-)

The next two days of Akademy were dedicated to the talks. This is year I think the most prominent talk was the one about Plasma Phone (the link contains a video of the talk). That was really exciting talk. I also like the fact that the work we did for Plasma Active is still alive and with a bright future ahead. Now I just need to figure out how to install Plasma Mobile in my smartphone :-)

Alex Fiestas' On how Agile, TDD, CI and CD are the same talk was also very interesting for me because I responsible for maintaining the continuous integration infrastructure in my daily work (besides being a developer and doing some administrative work too). I share Alex vision about the importance of continuous feedback. Nice tak Alex.

The last week of Akademy is reserved for BoFs and the day trip. I am a member of the Solid team and since Solid Maintainer could not attend Akademy I decided to schedule and conduct the Solid BoF this year. The BoF notes are here. The most important thing, for me, during the BoF was the decision to pass to Jan Grulich the Network Management maintainership. I will still work on network management for KDE, there are still some things I want to implement in Plasma NM.

I attended some other BoF, interesting and important things being discussed there. Sure this is an important part of Akademy.

The day trip happened on Wednesday we went to Aquarium Finisterrae and the Hercules tower area. Nice places to visit and I enjoyed every minute. Other things that I enjoyed was walking to the venue (nice view), the food :-) (except squid, I do not like eating squids :-P) and the weather (not too cold during the night and not too hot during the day).

That was one of my best Akademy's. A big thank you to the local team and Kenny Duffus for making Akademy such an enjoyable event. See you all at next Akademy.

Tuesday, April 7, 2015

NetworkManagerQt 0.9.8.4 is out

NetworkManagerQt is officially a Frameworks now. As a consequence the repository has been renamed from libnm-qt to networkmanager-qt and NMQt version number now follows Frameworks version number (currently 5.8.0).

NMQt 0.9.8.4 is the last release from the 0.9.8.x series. From NMQt 5.8.0 and on you need to install Frameworks instead of downloading it separately.

Bugs fixed in NMQt 0.9.8.4:

. Fix security type check for wireless connections.
. Fix secrets loading for openconnect connections.
339296: Fix vpn secrets loading.
. Update documentation.

Friday, March 6, 2015

Plasma NM 0.9.0.12

Plasma NM 0.9.0.12

SHA256Sum: 27b4a383972dcbb25eb254dcfe6b71ccb05ca0418590eb57ddc20c0b7bcac8eb

This is the last Plasma NM 0.9.0.x release, it is officially retired and unmaintained from now on. If you have not moved to Plasma NM 0.9.3.x please do it.

Changelog:

. Fixes OpenConnect NEWGROUP handling and build against OpenConnect > 7.0.
341387: OpenVPN: Add option for server certificate verification.
334246: Import/export 'redirect-gateway' option from openvpn configuration files.
282996: aborts connection editing once we find an error.

The following languages have more than 80% of strings translated:

bs ca ca@valencia cs da de el en_GB es et fi fr gl hu ia it kk km ko lt nb nds nl pl pt pt_BR ro ru sk sl sr sr@ijekavian sr@ijekavianlatin sr@latin sv tr uk zh_CN zh_TW

Also read some very usefull information about how to use and avoid problems when using Plasma NM in my past posts page.

Thursday, January 1, 2015

Retiring Plasma NN 0.9.0.x

I am in the process of retiring Plasma NM 0.9.0.x (aka old Plasma NM applet). The new applet (Plasma NM >= 0.9.8.x) is already shipped with all major distributions. I may release Plasma NM 0.9.0.12 with some few bugfixes if someone is interested in that. However after 0.9.0.12 there will be no further releases for the old applet. It will enter in unmaintained state and I will ask sysadmin to remove/disable NetworkManagement product from bugs.kde.org. There is already product plasma-nm to report bugs in the new applet.