<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Wayland on Major Hayden</title><link>https://major.io/tags/wayland/</link><description>Recent content in Wayland on Major Hayden</description><generator>Hugo</generator><language>en</language><managingEditor>major@mhtx.net (Major Hayden)</managingEditor><webMaster>major@mhtx.net (Major Hayden)</webMaster><copyright>All content licensed &lt;a href="https://creativecommons.org/licenses/by-sa/4.0/"&gt;CC BY-SA 4.0&lt;/a&gt;</copyright><lastBuildDate>Mon, 09 Nov 2026 20:39:15 -0600</lastBuildDate><atom:link href="https://major.io/tags/wayland/index.xml" rel="self" type="application/rss+xml"/><item><title>Fix big cursors in Java applications in Wayland</title><link>https://major.io/p/java-big-cursors-wayland/</link><pubDate>Fri, 26 Apr 2024 00:00:00 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/java-big-cursors-wayland/</guid><description>&lt;p&gt;Scroll through the list of &lt;a href="https://major.io/tags/wayland/"&gt;Wayland posts&lt;/a&gt; posts on the blog and you&amp;rsquo;ll see that I&amp;rsquo;ve solved plenty of weird problems with Wayland and the &lt;a href="https://swaywm.org/"&gt;Sway&lt;/a&gt; compositor.&#10;Most are pretty easy to fix but some are a bit trickier.&lt;/p&gt;&#10;&lt;p&gt;Java applications are notoriously unpredictable and Wayland takes unpredictability to the next level.&#10;One particular application on my desktop always seems to start with massive cursors.&lt;/p&gt;&#10;&lt;p&gt;This post is about how I fixed and then discovered something interesting along the way.&lt;/p&gt;&#10;&lt;h2 id="fixing-big-cursors"&gt;Fixing big cursors&lt;/h2&gt;&#10;&lt;p&gt;I recently moved some investment and trading accounts from TD Ameritrade to &lt;a href="https://tastytrade.com/"&gt;Tastytrade&lt;/a&gt;.&#10;Both offer Java applications that make trading easier, but Tastytrade&amp;rsquo;s application always started with massive cursors.&lt;/p&gt;&#10;&lt;p&gt;To make matters worse, sometimes the cursor looked lined up on the screen but then the click landed on the wrong buttons in the application!&#10;Errors are annoying.&#10;Errors that cost you money and time must be fixed. 😜&lt;/p&gt;&#10;&lt;p&gt;Some web searches eventually led me to Arch Linux&amp;rsquo;s excellent &lt;a href="https://wiki.archlinux.org/title/Wayland"&gt;Wayland wiki page&lt;/a&gt;.&#10;None of the adjustments or environment variables there had any effect on my cursors.&lt;/p&gt;&#10;&lt;p&gt;I eventually landed on a page that suggested setting &lt;code&gt;XCURSOR_SIZE&lt;/code&gt;.&#10;I don&amp;rsquo;t remember ever setting that, but it was being set by &lt;em&gt;something&lt;/em&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$XCURSOR_SIZE&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;24&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;One of the suggestions was to decrease it, so I decided to give &lt;code&gt;20&lt;/code&gt; a try.&#10;That was too big, but &lt;code&gt;16&lt;/code&gt; was perfect and it matched all of my other applications:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;XCURSOR_SIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;#&lt;/span&gt; /opt/tastytrade/bin/tastytrade&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That works fine when I start my application via the terminal, but how do I set it for the application when I start it from ulauncher in sway? 🤔&lt;/p&gt;&#10;&lt;h2 id="desktop-file"&gt;Desktop file&lt;/h2&gt;&#10;&lt;p&gt;The Tastytade RPM comes with a &lt;code&gt;.desktop&lt;/code&gt; file for launching the application.&#10;I copied that over to my local applications directory:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cp /opt/tastytrade/lib/tastytrade-tastytrade.desktop &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ~/.local/share/applications/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then I opened the copied &lt;code&gt;~/.local/share/applications/tastytrade-tastytrade.desktop&lt;/code&gt; file in a text editor:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;[Desktop Entry]&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;tastytrade&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;Comment&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;tastytrade&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;Exec&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/opt/tastytrade/bin/tastytrade&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;Icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/opt/tastytrade/lib/tastytrade.png&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;Terminal&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;false&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;Application&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;Categories&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;tastyworks&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;MimeType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I changed the &lt;code&gt;Exec&lt;/code&gt; line to be:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;Exec&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;env XCURSOR_SIZE=16 /opt/tastytrade/bin/tastytrade&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I launched the application again after making that change, but the cursors were still huge!&#10;There has to be another way. 🤔&lt;/p&gt;&#10;&lt;h2 id="systemd-does-everything-"&gt;systemd does everything 😆&lt;/h2&gt;&#10;&lt;p&gt;After more searching and digging, I discovered that systemd has a capability to &lt;a href="https://www.freedesktop.org/software/systemd/man/latest/environment.d.html"&gt;set environment variables for user sessions&lt;/a&gt;:&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;Configuration files in the environment.d/ directories contain lists of environment variable assignments passed to services started by the systemd user instance. systemd-environment-d-generator(8) parses them and updates the environment exported by the systemd user instance. See below for an discussion of which processes inherit those variables.&lt;/p&gt;&#10;&lt;p&gt;It is recommended to use numerical prefixes for file names to simplify ordering.&lt;/p&gt;&#10;&lt;p&gt;For backwards compatibility, a symlink to /etc/environment is installed, so this file is also parsed.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;Let&amp;rsquo;s give that a try:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; mkdir -p ~/.config/environment.d/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; vim ~/.config/environment.d/wayland.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the file, I added one line with a comment (because you will soon forget why you added it 😄):&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Fix big cursors in Java apps in Wayland&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;XCURSOR_SIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;16&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;After a reboot, I launched my Java application and boom &amp;ndash; the cursors were perfect!&lt;/strong&gt; 🎉&lt;/p&gt;&#10;&lt;p&gt;I went back and cleaned up some other hacks I had applied and added them to that &lt;code&gt;wayland.conf&lt;/code&gt; file:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# This was important at some point but I&amp;#39;m afraid to remove it.&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Note to self: make detailed comments when adding lines here.&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;SDL_VIDEODRIVER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;wayland&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;QT_QPA_PLATFORM&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;wayland&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Reduce window decorations for VLC&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;QT_WAYLAND_DISABLE_WINDOWDECORATION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;1&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Fix weird window handling when Java apps do certain pop-ups&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;_JAVA_AWT_WM_NONREPARENTING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Ensure Firefox is using Wayland code (not needed any more)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;MOZ_ENABLE_WAYLAND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Disable HiDPI&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;GDK_SCALE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Fix big cursors in Java apps in Wayland&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;XCURSOR_SIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;16&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I&amp;rsquo;m told there are some caveats with this solution, especially if your Wayland desktop doesn&amp;rsquo;t use systemd to start.&#10;This is working for me with GDM launching Sway on Fedora 40.&lt;/p&gt;&#10;</description></item><item><title>Efficient emoji experience in Wayland</title><link>https://major.io/p/efficient-emoji-experience-wayland/</link><pubDate>Fri, 27 May 2022 00:00:00 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/efficient-emoji-experience-wayland/</guid><description>&lt;p&gt;I recently moved over to the Sway window manager (as I mentioned in my &lt;a href="https://major.io/p/sway-reload-causes-firefox-crash/"&gt;last post&lt;/a&gt;) and&#10;it runs on Wayland. That means bidding farewell to X. Although this is a step forward,&#10;it caused some of my workflows to break.&lt;/p&gt;&#10;&lt;p&gt;My original post about my &lt;a href="https://major.io/2021/05/15/efficient-emojis-with-rofimoji/"&gt;efficient emoji workflow&lt;/a&gt; inspired many people to give it a&#10;try. Everything was great until I moved to Wayland and suddenly &lt;a href="https://github.com/fdw/rofimoji"&gt;rofimoji&lt;/a&gt; stopped&#10;pasting emojis on demand. 😱&lt;/p&gt;&#10;&lt;h1 id="so-is-this-a-big-deal-or-something"&gt;So is this a big deal or something?&lt;/h1&gt;&#10;&lt;p&gt;Well, yes.&lt;/p&gt;&#10;&lt;p&gt;Some people would shrug this off and go on about their day. But wait &amp;ndash; emojis are core&#10;to my workflow. Sure, I use them liberally in my communications via chat or email, but I&#10;also sprinkle them in various places to ensure applications handle unicode characters&#10;properly.&lt;/p&gt;&#10;&lt;p&gt;When I worked on the Continuous Kernel Integration (CKI) team at Red Hat, we wanted to&#10;send concise and informative emails in plain text. Our team added &lt;a href="https://www.spinics.net/lists/linux-block/msg68704.html"&gt;colorful emoji&#10;symbols&lt;/a&gt;, reduced the length of our emails, and won praise (and some consternation) from&#10;kernel developers. We even named our releases using emojis for a while (the first one&#10;was 🐣). 🤭&lt;/p&gt;&#10;&lt;h1 id="emojis-in-wayland"&gt;Emojis in wayland&lt;/h1&gt;&#10;&lt;p&gt;In Fedora, we need some packages:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; sudo dnf install rofimoji wl-clipboard wtype&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Why do we need these?&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;rofimoji&lt;/code&gt; pops up an emoji picker in rofi where you can quickly search for emojis&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;wl-clipboard&lt;/code&gt; gives you the &lt;code&gt;wl-copy&lt;/code&gt; and &lt;code&gt;wl-paste&lt;/code&gt; tools, similar to &lt;code&gt;xclip&lt;/code&gt; from X&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;wtype&lt;/code&gt; replaces &lt;code&gt;xdotool&lt;/code&gt; from X&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Sway is &lt;em&gt;heavily&lt;/em&gt; keyboard driven and that&amp;rsquo;s why I love it. More typing and less mouse.&#10;We need a keyboard shortcut for &lt;code&gt;rofimoji&lt;/code&gt;. I use MOD-D for regular &lt;code&gt;rofi&lt;/code&gt;, so I chose&#10;to use MOD-E for &lt;code&gt;rofimoji&lt;/code&gt;. (&lt;em&gt;MOD&lt;/em&gt; is likely the key on your keyboard with the Windows&#10;logo on it.)&lt;/p&gt;&#10;&lt;p&gt;Open your sway configuration file (usually &lt;code&gt;~/.config/sway/config&lt;/code&gt;) and add a line:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;bindsym $mod+e exec ~/bin/launch_rofimoji&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Save the shell script to &lt;code&gt;~/bin/launch_rofimoji&lt;/code&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;#!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Determine which output is currently active (where the mouse pointer is). 🤔&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;MONITOR_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;XWAYLAND&lt;span class="k"&gt;$(&lt;/span&gt;swaymsg -t get_outputs &lt;span class="p"&gt;|&lt;/span&gt; jq &lt;span class="s1"&gt;&amp;#39;[.[].focused] | index(true)&amp;#39;&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Let&amp;#39;s pick our emojis! 🎉&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rofimoji --action &lt;span class="nb"&gt;type&lt;/span&gt; --skin-tone light &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --selector-args&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;-theme solarized -font &amp;#39;Hack 12&amp;#39; -monitor &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;MONITOR_ID&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Ensure the script is executable:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; chmod +x ~/bin/launch_rofimoji&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At this point, you can reload sway&amp;rsquo;s configuration with MOD+SHIFT-C. After a brief&#10;screen flicker, try the MOD+E keyboard combination and &lt;code&gt;rofimoji&lt;/code&gt; should appear! Search&#10;for your favorite emoji, press enter, and enjoy! 🍰&lt;/p&gt;&#10;&lt;h1 id="caveats"&gt;Caveats&lt;/h1&gt;&#10;&lt;p&gt;This script works well for me terminals, Visual Studio Code, Firefox, and most GTK-based&#10;applications. However, I still have issues using it with Electron based applications&#10;(such as Slack). If I bind a sway key combination to something super simple, like &lt;code&gt;wtype banana&lt;/code&gt;, I end up with numbers pasted into Electron applications. That&amp;rsquo;s something I am&#10;still working to solve&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#10;&lt;p&gt;If you run into issues where emojis don&amp;rsquo;t appear, or you have unusual carriage returns&#10;after your emojis, you may want to remove &lt;code&gt;--action type&lt;/code&gt; and try &lt;code&gt;--action copy&lt;/code&gt; or&#10;&lt;code&gt;--action clipboard&lt;/code&gt;. These different actions use different methods for copying and&#10;pasting emojis into your applications. You can stack actions separated by spaces, such&#10;as &lt;code&gt;--action clipboard type&lt;/code&gt;. You may need to experiment with these to figure out what&#10;works on your machine.&lt;/p&gt;&#10;&lt;p&gt;Still having trouble? Consider using &lt;code&gt;clipman&lt;/code&gt;. It&amp;rsquo;s a more robust clipboard for wayland&#10;and you can start it automatically in sway:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;exec wl-paste -t text --watch clipman store --no-persist&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can query &lt;code&gt;clipman&lt;/code&gt; history as well. This could help you determine what&amp;rsquo;s not being&#10;copied across correctly from rofimoji.&lt;/p&gt;&#10;&lt;div class="footnotes" role="doc-endnotes"&gt;&#10;&lt;hr&gt;&#10;&lt;ol&gt;&#10;&lt;li id="fn:1"&gt;&#10;&lt;p&gt;My workaround is to use Slack in Firefox. I&amp;rsquo;d love to just stop&#10;using Slack altogether, but I don&amp;rsquo;t have a choice. 😭&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/div&gt;&#10;</description></item><item><title>Sway reload causes a Firefox crash</title><link>https://major.io/p/sway-reload-causes-firefox-crash/</link><pubDate>Tue, 24 May 2022 00:00:00 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/sway-reload-causes-firefox-crash/</guid><description>&lt;p&gt;My workday takes me from email to terminals to browsers to documents. I love tiling&#10;window managers because they keep me organized and less distracted. Many are less&#10;resource-intensive as well.&lt;/p&gt;&#10;&lt;p&gt;Although &lt;a href="https://i3wm.org/"&gt;i3&lt;/a&gt; has graced my displays for years now (and I&amp;rsquo;ve &lt;a href="https://major.io/tags/i3/"&gt;written many posts about&#10;it&lt;/a&gt;), I recently picked up an AMD graphics card and made my way to &lt;a href="https://swaywm.org"&gt;sway&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;The biggest difference between the two is that sway runs on &lt;a href="https://wayland.freedesktop.org/"&gt;Wayland&lt;/a&gt; rather than X.&#10;Sway has control over how nearly everything works, such as input devices, displays,&#10;backgrounds, and more. If you were frustrated with lots of hacks in i3 for various&#10;X-related things, you might enjoy sway.&lt;/p&gt;&#10;&lt;h1 id="but-then-stuff-breaks"&gt;But then stuff breaks&lt;/h1&gt;&#10;&lt;p&gt;Much of my early experience with sway involves this process:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Change a configuration in sway 1.7.1&lt;/li&gt;&#10;&lt;li&gt;Reload the configuration live&lt;/li&gt;&#10;&lt;li&gt;Scrunch my face and say &amp;ldquo;Well, that&amp;rsquo;s not quite right.&amp;rdquo;&lt;/li&gt;&#10;&lt;li&gt;Read the docs&lt;/li&gt;&#10;&lt;li&gt;Go to step #1 😉&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Fortunately, sway puts up with my constant reloads of the configuration until one day&#10;when I changed lots of configuration items and suddenly every reload caused Firefox to&#10;crash. My primary version of Firefox is the &lt;a href="https://www.mozilla.org/en-US/firefox/developer/"&gt;Developer Edition&lt;/a&gt; (currently 101.0b9), but&#10;I also keep a stable version of Firefox (version 100) around that Fedora provides.&lt;/p&gt;&#10;&lt;p&gt;I started up the default Fedora version of Firefox, reloaded the configuration in sway,&#10;and the stable Firefox crashed, too. 🔥&lt;/p&gt;&#10;&lt;p&gt;Nothing appeared on the screen when Firefox crashed. The window just disappeared and my&#10;terminal filled up the screen where Firefox was. I could reproduce the crash multiple&#10;times with both versions of Firefox. The crash kept occurring even after a reboot.&lt;/p&gt;&#10;&lt;p&gt;When I ran either version of Firefox from the command line, I finally got some error&#10;output:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Lost connection to Wayland compositor.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Exiting due to channel error.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Exiting due to channel error.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Exiting due to channel error.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Exiting due to channel error.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Exiting due to channel error.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Exiting due to channel error.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Exiting due to channel error.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Exiting due to channel error.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Hmm, it looks like Firefox can&amp;rsquo;t talk to Sway for a moment and that might cause the&#10;crash. But why did this suddenly start happening?&lt;/p&gt;&#10;&lt;h1 id="working-backwards"&gt;Working backwards&lt;/h1&gt;&#10;&lt;p&gt;I gradually backed out the recent sway configuration changes and finally found&#10;the configuration involved in the crash:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;input * {&#10; # Enable numlock when sway starts.&#10; xkb_numlock enable&#10; # Set up compose keys.&#10; xkb_options compose:rctrl&#10;}&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If I removed that section, Firefox stopped crashing on sway config reloads. If I put it&#10;back in, Firefox crashed.&lt;/p&gt;&#10;&lt;p&gt;I tried removing only the &lt;code&gt;xkb_numlock&lt;/code&gt; line. Firefox crashed. The same thing happened&#10;when I removed only the &lt;code&gt;xkb_options&lt;/code&gt; line.&lt;/p&gt;&#10;&lt;p&gt;Sway&amp;rsquo;s documentation notes that you can &lt;a href="https://github.com/swaywm/sway/wiki#key-bindings-on-a-dual-usrussian-layout"&gt;apply input configuration to all devices&lt;/a&gt; with&#10;&lt;code&gt;input *&lt;/code&gt;, so the configuration was valid.&lt;/p&gt;&#10;&lt;h1 id="search-time"&gt;Search time&lt;/h1&gt;&#10;&lt;p&gt;Armed with an error message and a method for reproducing my crash, I set off to use the&#10;most powerful system administrator tool on the market: Google. 😜&lt;/p&gt;&#10;&lt;p&gt;I landed on &lt;a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1652820"&gt;Mozilla Bug 1652820&lt;/a&gt; where other Firefox users noted that sway config&#10;reloads caused crashes for them, too. A user noted &lt;a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1652820#c28"&gt;further down in the bug&lt;/a&gt; that if&#10;they removed the &lt;code&gt;*&lt;/code&gt; from their &lt;code&gt;input&lt;/code&gt; configuration and specified the actual device&#10;identifier, the problem went away.&lt;/p&gt;&#10;&lt;h1 id="fixing-the-crash"&gt;Fixing the crash&lt;/h1&gt;&#10;&lt;p&gt;I ran back and looked at my problematic configuration:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;input * {&#10; xkb_numlock enable&#10; xkb_options compose:rctrl&#10;}&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now the big question: how do I identify my keyboard? 🤔&lt;/p&gt;&#10;&lt;p&gt;As I mentioned before, sway controls everything, including input devices. You can query&#10;about things that sway knows by using &lt;code&gt;swaymsg&lt;/code&gt; and it automatically dumps data in JSON&#10;format if you use a pipe:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; swaymsg -t get_inputs &lt;span class="p"&gt;|&lt;/span&gt; jq -r &lt;span class="s1"&gt;&amp;#39;.[].identifier&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; grep -i keyboard&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;1241:662:USB-HID_Keyboard&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;1241:662:USB-HID_Keyboard_Mouse&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;1241:662:USB-HID_Keyboard_Consumer_Control&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;1241:662:USB-HID_Keyboard_System_Control&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;1241:662:USB-HID_Keyboard&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;My keyboard is identified as &lt;code&gt;1241:662:USB-HID_Keyboard&lt;/code&gt; according to sway. I updated my&#10;input configuration to specify the exact device:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;input &amp;#34;1241:662:USB-HID_Keyboard&amp;#34; {&#10; xkb_numlock enable&#10; xkb_options compose:rctrl&#10;}&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I reloaded the sway configuration, started Firefox, reloaded the configuration once&#10;more, and &lt;strong&gt;Firefox was still running&lt;/strong&gt;. 🎉&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;🐙 &lt;em&gt;Have multiple keyboards or input devices?&lt;/em&gt; Other users noted in the bug report&#10;that the crash will happen again (even with specific identifiers) if you have two&#10;keyboards and both keyboards are connected. If you run into this problem, another user&#10;&lt;a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1652820#c51"&gt;shared their workaround&lt;/a&gt; using &lt;code&gt;swaymsg&lt;/code&gt; called via &lt;code&gt;exec&lt;/code&gt;.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;</description></item></channel></rss>