<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bouteiller &lt; A2N &gt; Alan on Medium]]></title>
        <description><![CDATA[Stories by Bouteiller &lt; A2N &gt; Alan on Medium]]></description>
        <link>https://medium.com/@a2nb?source=rss-e93261f2c14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rMUjXaTUQet1PwlhY7j1bA.png</url>
            <title>Stories by Bouteiller &amp;lt; A2N &amp;gt; Alan on Medium</title>
            <link>https://medium.com/@a2nb?source=rss-e93261f2c14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:36:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@a2nb/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Get KDE plasma 6 on Arch]]></title>
            <link>https://a2nb.medium.com/get-kde-plasma-6-on-arch-1ca8cf7818b4?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ca8cf7818b4</guid>
            <category><![CDATA[arch-linux]]></category>
            <category><![CDATA[updates]]></category>
            <category><![CDATA[kde]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Thu, 29 Feb 2024 10:04:55 GMT</pubDate>
            <atom:updated>2024-03-01T07:45:21.239Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get KDE plasma 6 on Arch — the one minute setup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BAMSiBt9piBjG029aftTzA.png" /></figure><p>ATM the new version of KDE plasma is not available yet on the extra repository of arch. But it is on the extra/testing repository !</p><figure><img alt="screen capture of the arch repository list for plasma desktop" src="https://cdn-images-1.medium.com/max/763/1*3Nmm3k-UGbMDvuM7mJyOXw.png" /></figure><p>There is a simple step by step explanation on how to move to it.</p><p>First, if you want to see all the plasma related package, you can do it with pacman like that :</p><pre>$ sudo pacman -Qe | grep plasma<br>eos-plasma-sddm-config 22.03.1.2-1<br>eos-settings-plasma 1.5-1<br>kdeplasma-addons 5.27.10-2<br>plasma-desktop 5.27.10-1<br>plasma-disks 5.27.10-1<br>plasma-nm 5.27.10-1<br>plasma-pa 5.27.10-1<br>plasma-systemmonitor 5.27.10-1</pre><p>Then you have two options : a rapid one and a more complex one.</p><p>The rapid option is very simple, you just move from extra to extra/testing.</p><p>The more complex one is the same, but you set a couple more of parameter in the pacman configuration file for updating only the package you want. The downside is that you have to enter the full list of package you want to move from extra to extra/testing.</p><h3>The rapid option</h3><p>We open the pacman configuration file :</p><pre>nvim /etc/pacman.conf</pre><p>And we need to seek for the repository section, it looks like that :</p><figure><img alt="Screen capture of the repository section of the pacman.conf file" src="https://cdn-images-1.medium.com/max/967/1*z6nh_I44pI8BwQX-tR9O7Q.png" /></figure><p>Here you can see that the <strong><em>extra-testing</em></strong> part is commented. So we just need to remove the <strong><em>#</em></strong> part and uncomment it.</p><p>There you should have something like that :</p><pre><br>[endeavouros]<br>SigLevel = PackageRequired<br>Include = /etc/pacman.d/endeavouros-mirrorlist<br><br>#[core-testing]<br>#Include = /etc/pacman.d/mirrorlist<br><br>[core]<br>Include = /etc/pacman.d/mirrorlist<br><br>[extra-testing]<br>Include = /etc/pacman.d/mirrorlist<br><br>[extra]<br>Include = /etc/pacman.d/mirrorlist</pre><p>So, after that, we need to sync all that :</p><pre>pacman -Syu</pre><p>And after some question, for example for moving baloo to testing, hit a reboot and voilà ! You have plasma 6.</p><h3>The more complex option</h3><p>If you want to pick, by hand, all the package you want to move you have to add a little extra line to your pacman.conf file :</p><pre>[extra-testing]<br>Include = /etc/pacman.d/mirrorlist<br>Usage = Sync Search</pre><p>Here, the usage parameter gives us the possibility to be specific when we want to install something from the extra/testing repository !</p><p>And all the other packages keep working with the extra repository (for example when you do a pacman -Syu) 🙂</p><p>Then next you can sync :</p><pre>pacman -Sy</pre><p>After that, you have to pick all the package you want to move. A quick way to check the list is to initiate a sync with the list of package we have found with pacman -Qe :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RwJoQzD4Xp7fTS3dFg8Tig.png" /></figure><p>And next rerun your pacman -Syu with all the package name.</p><p>— — — — — —</p><p>Then enjoy your brand-new plasma 6 🥳</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*--Dex_TIxxl51JowYIz3fA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*ex8W5Xzj6H69HdiUdF1nMw.png" /></figure><h3>How to go back when the release is out on extra ?</h3><p>You just have to remove the following line to your pacman.conf file :</p><pre>[extra-testing]<br>Include = /etc/pacman.d/mirrorlist<br>Usage = Sync Search</pre><p>and do a pacman -Syu, reboot and done !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ca8cf7818b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing tech debt]]></title>
            <link>https://a2nb.medium.com/managing-tech-debt-d1e600739300?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1e600739300</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[technical-debt]]></category>
            <category><![CDATA[team-collaboration]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Wed, 24 Jan 2024 13:02:35 GMT</pubDate>
            <atom:updated>2024-01-24T13:02:35.154Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3j-vyPPZOPCGBR0jG5BYLQ.png" /><figcaption>Dall-e generated image</figcaption></figure><p>Okay, give me a super common situation in tech.</p><p>It starts with tech and finishes with debt 😇</p><p>Yeah, tech debt, the horror situation for any tech team 😱</p><p>Or — maybe not?</p><p>How to manage this kind of stuff? Build a pool with this dead code under it and forget it?</p><p>The first step is pretty simple: breathe — keep calm — this is fine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQaDaSOAm3cmX-NrCLqv0g.png" /><figcaption>Dall-e generated image</figcaption></figure><p>Damn, this coffee is pretty good ☕</p><p>Oh sorry, I’m too relaxed. But, hey, you can be too 😉</p><p>Most of the time you don’t have the luxury to create good architecture or well-documented code. And that’s perfectly fine!</p><p>The priority is traction 🚜💨 you don’t want to have very clean code but 0 customers to enjoy it. And once you have income, you have time to clean up!</p><p>Ok, now you have money and a mess. How to proceed?</p><p>1 — <strong>Measure</strong> — not simple to measure this kind of debt, but find a way to measure it and stick to follow this measure over time.</p><p>2 — <strong>Time allocation</strong> — if you need to clean something, you need time, don’t you? It’s the same thing with tech debt. Agree, with all the parties, how much time you’re okay to spend on that task each week or each sprint.</p><p>3 — <strong>Repeat</strong> — didn’t see that coming, don&#39;t you ? 🙃 monitor your progress and readjust the time allocation according to your needs.</p><p>You can also add a 4th step: share and celebrate, but it’s up to you 😉</p><p>Ok now, the wolf in the sheepfold: Measure.</p><p>Some ideas:</p><ul><li>If you use DORA metrics, you can extrapolate the debt measure. For example, if you have a high Change Failure Rate or a high Mean Time To Recovery, maybe it’s time to clean the code?</li><li>Use your tasks or issues tracker. Add a tag, like “debt”, ask your devs to tag the tasks that have debt and estimate them. Eventually, you’ll get a sum of these estimates and have a measure 🥳</li><li>Just ask. Who is the best person to know this debt? Yes, the devs. So, why not just ask on a weekly basis? Ask, note, and make a decision.</li></ul><p>The only rule you have to follow for the measure is the following: be consistent. Do not change your way of measuring the debt, and measure regularly.</p><p>Oh! And a very important point: agree on the time allocation with your entire org. Not just the devs. Everyone has to know that you have planned work for this task and why you do it.</p><p>So don’t be afraid, take a measure, allow, for a start, 10 to 20% of your time, inform everyone, and adjust over time.</p><p>That’s all folks, thanks for reading :)</p><p><a href="https://www.sleuth.io/post/dora-metrics-explained/](https://www.sleuth.io/post/dora-metrics-explained/">Click here if you want to learn more about DORA.</a></p><p>Don&#39;t forget to clap 👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1e600739300" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Submitting a package to the AUR — full tutorial]]></title>
            <link>https://a2nb.medium.com/submitting-a-package-to-the-aur-full-tutorial-e4133f86e98c?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4133f86e98c</guid>
            <category><![CDATA[arch]]></category>
            <category><![CDATA[package]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Fri, 24 Nov 2023 18:29:42 GMT</pubDate>
            <atom:updated>2023-11-24T18:29:42.821Z</atom:updated>
            <content:encoded><![CDATA[<h3>Submitting a package to the AUR — full tutorial</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4QceTqCoUYvWvDxr_Ma42A.png" /></figure><p><a href="https://a2nb.medium.com/submitting-a-package-to-the-aur-e9117d07494d">You can find another story about submitting a tarball file into the AUR just here.</a></p><p><a href="https://youtu.be/0mljAaJqYpM">This tutorial is also available on YouTube.</a></p><p>You want to support me: applaud this story, check the video or leave a comment!</p><p>Today we are going to see how to publish a package to the AUR from a git source. And, btw, the tutorial works with any other version manager in theories.</p><p>In <a href="https://a2nb.medium.com/submitting-a-package-to-the-aur-e9117d07494d">another story</a> I have talked about how to make a submission to the AUR with a tarball file, the main difference between the two methods are how we handle the source and how we validate them.</p><p>For this tutorial I’m going to use my <a href="https://github.com/bouteillerAlan/blurredwallpaper">blurredwallpaper project</a>, so mind to update the version, source, name and so on in function of your project.</p><h3>Some prerequisite</h3><p>For a git source we are going to use a gpg key when, for a tarball, we can just use a checksum.<br>This is important because I sign my commit and my tag with a gpg key, and like so we can tell our source to get the tag in question and check if the gpg signature is valid.</p><p>For signing your commit, you need to have a gpg key. You can create one with <strong><em>gpg </em></strong>or <strong><em>gpg2</em></strong>. This is pretty simple, we can do that with the following command:</p><pre>gpg2 --full-generate-key</pre><p>Then you have to tell git that you want to sign your commit and your tag and for that we need to have the id of the key.<br>For that, you just have to use:</p><pre>gpg2 --list-secret-keys --keyid-format=long</pre><p>The id is this number: <strong><em>3AA5C34371567BD2</em></strong> just at the <strong><em>sec </em></strong>line.</p><pre>$ gpg2 --list-secret-keys --keyid-format=long<br>/Users/hubot/.gnupg/secring.gpg<br> - - - - - - - - - - - - - - - - - - <br>sec 4096R/3AA5C34371567BD2 2016–03–10 [expires: 2017–03–10]<br>uid Hubot &lt;hubot@example.com&gt;<br>ssb 4096R/4BB6D45482678BE3 2016–03–10</pre><p>Next you have to execute this commands, the first one tells to git to use the key previously created and the second tell to git to actually sign your commit:</p><pre>git config --global user.signingkey 3AA5C34371567BD2<br>git config --global commit.gpgsign true</pre><p>And for a tag it is less automated, you need to add the <strong><em>-s</em></strong> flag when you create a tag, keep in mind the command we are going to use it very soon:</p><pre>git tag -s MYTAG</pre><h3>Initialization</h3><p>First, we are going to create a new directory and init our git repository:</p><pre>mkdir mypackage<br>cd mypackage<br>git init</pre><p>And now we can go for the real deal: the PKGBUILD file!</p><p>We can copy the prototype file from this arch wiki page: <a href="https://wiki.archlinux.org/title/Arch_package_guidelines">https://wiki.archlinux.org/title/Arch_package_guidelines</a> and delete all the keys we don’t need and update the maintainer field:</p><pre># Maintainer: Your Name &lt;youremail@domain.com&gt;<br>pkgname=&quot;mypkgname-git&quot;<br>pkgver=1.0.0<br>pkgrel=1<br>pkgdesc=&quot;&quot;<br>arch=(&quot;any&quot;)<br>url=&quot;&quot;<br>license=(&#39;GPL&#39;)<br>depends=()<br>makedepends=()<br>optdepends=()<br>source=()<br>md5sums=(&quot;SKIP&quot;)<br><br>pkgver() {}<br><br>package() {}</pre><p>Ok! We have the base of our file.</p><p>So, some important things here:<br>- the <strong><em>pkgver </em></strong>key must be the same as the version number of your project<br>- because we are going to use a git source, we have to add <strong><em>-git</em></strong> at the end of the package name in <strong><em>pkgname</em></strong><br>- the <strong><em>pkgver()</em></strong> function is use with git tag to update the version of our package automatically if needed<br>- because we are going to use gpg to validate the source, we can <strong><em>”SKIP”</em></strong> the <strong><em>md5sums</em></strong> check</p><h3>Adding the source</h3><p>Like I said at the beginning, we are going to use a git source and not a tarball. And because it’s a git source, we need to have a way to focus a particular version of our code. And for that, git gives us access to tags.</p><p>So the first step is to create a tag, signed by gpg, representing the commit of your current project version. And obviously you need to do that in the project repository, not on the PKGBUILD repository. For me, it’s the last commit so I just have to go on my main branch and do :</p><pre>git tag -s v2.2.0</pre><p>Ok, now we have a tag signed by gpg!</p><p>Next, we need to add a new variable into our PKGBUILD file <strong><em>_tag</em></strong>. The <strong><em>_</em></strong> is part of the package etiquette defined in the arch wiki, so it’s mandatory.</p><p>The <strong><em>_tag</em></strong> variables may contain the tag we just created before, but we can’t put its row value (v2.2.0) because if, for some reason, we push force another commit on the tag, the tag remains the same but the commit change. So for avoiding that we have to use the hash of the tag.<br>For that, we just have to go on the main branch of our project and get the hash of the last tag via <strong><em>git rev-parse v2.2.0</em></strong> that give us the hash: <strong><em>123456789123456789</em></strong>.</p><p>Now that we have the variable <strong><em>_tag</em></strong> populated with our hash, we can use that to set the right url for the <strong><em>source </em></strong>key:</p><pre>url=&quot;https://github.com/bouteillerAlan/blurredwallpaper&quot;<br>source=(&quot;git+${url}.git#tag=${_tag}?signed&quot;)</pre><h3>Validating the source</h3><p>Ok now we need to validate the source via the tag signed by gpg.<br>The process is very simple, the first step is to add our gpg key into a gpg server. This is mandatory because we need to have our key available on the net, like so when user installed our package the process can check the key automatically.</p><p>The easiest way of doing that is to add our key to a public server, for example: <a href="https://keyserver.ubuntu.com/">https://keyserver.ubuntu.com</a>.</p><p>You can do it automatically via the “Publish on server…” button <a href="https://www.openpgp.org/software/kleopatra/">kleopatra </a>or manually directly via the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*CGWerPjSYlDjQSs6ePVSIg.png" /></figure><p>And next we just have to add the id of the key to a new key in our PKGBUILD file :</p><pre>validpgpkeys=(<br>  6A2ECC8A396F8A943A109A1E0F11C2A6BF79111E<br>)</pre><h3>Updating the pkgver</h3><p>With the use of a git source, we can update the `pkgver` automatically via the following function:</p><pre>_sourceName=&quot;blurredwallpaper&quot;<br>pkgver() {<br>  cd &quot;${_sourceName}&quot;<br>  git describe --tags | sed &#39;s/^v//&#39;<br>}</pre><p>Here I have created a new variable <strong><em>_sourceName</em></strong> populated with the name of my repository.<br>Then we cd in the clone of our repository and get the last tag. The <strong><em>sed</em></strong> option is just here for deleting the <strong><em>v</em></strong> at the start of our tag.</p><p>Ok, now so far we have the following file:</p><pre># Maintainer: Your Name &lt;youremail@domain.com&gt;<br>_tag=123456789123456789<br>_sourceName=&quot;blurredwallpaper&quot;<br><br>pkgname=&quot;kdeplasma-blurredwallpaper-git&quot;<br>pkgver=2.2.0<br>pkgrel=1<br>pkgdesc=&quot;KDE plasma wallpaper plugin that blur the wallpaper when a window is active&quot;<br>arch=(&quot;any&quot;)<br>url=&quot;https://github.com/bouteillerAlan/blurredwallpaper&quot;<br>license=(&quot;GPL3&quot;)<br>depends=()<br>makedepends=()<br>optdepends=()<br>source=(&quot;git+${url}.git#tag=${_tag}?signed&quot;)<br>md5sums=(&quot;SKIP&quot;)<br>validpgpkeys=(6A2ECC8A396F8A943A109A1E0F11C2A6BF79111E)<br><br>pkgver() {<br>  cd &quot;${_sourceName}&quot;<br>  git describe --tags | sed &#39;s/^v//&#39;<br>}<br><br>package() {}</pre><h3>The (mostly) last step : packaging</h3><p>For finishing up our PKGBUILD file, we have to add the dependencies and set the mandatory <strong><em>package()</em></strong> function.</p><p>The dependencies are linked to your project so you have to check that your dependencies are correct. But we have some key points here :<br>- the <strong><em>depends</em></strong> option is for your project dependencies, in my project I don’t have any dependencies<br>- the <strong><em>optdepends</em></strong> option if you have optional dependencies, same for me no optional dependencies in my project<br>- the <strong><em>makedepends</em></strong> option where you have to add <strong><em>git</em></strong> because we create a package sourced from git (and use git in the <strong><em>pkgver()</em></strong> function for example)</p><p>Next, we have to implement the mandatory <strong><em>package()</em></strong> function:</p><pre># we cd into the project folder<br>cd &quot;${_sourceName}&quot;<br># place the license file into the right directory<br>install -Dm 644 LICENSE -t &quot;${pkgdir}&quot;/usr/share/licenses/&quot;${pkgname}&quot;/<br># we create the plasmoid directory<br>mkdir -p &quot;${pkgdir}/usr/share/plasma/wallpapers/${_plasmoidName}&quot;<br><br># and we place our project into the right directory<br>install -Dm 644 metadata.json -t &quot;${pkgdir}&quot;/usr/share/plasma/wallpapers/&quot;${_plasmoidName}&quot;/<br>find &quot;contents&quot; -type f -exec install -Dm 644 &quot;{}&quot; &quot;${pkgdir}/usr/share/plasma/wallpapers/${_plasmoidName}/{}&quot; \;</pre><p>The first two commands are very simple, the <strong><em>install </em></strong>command is recommended in place of the <strong><em>cp </em></strong>command because <strong><em>install </em></strong>can also handle permissions.</p><p>The last command use <strong><em>find </em></strong>for listing all the directories and files, and next use install to move all that into the right directory.</p><p>Also we use another variable <strong><em>_plasmoidName</em></strong> that has been populated with the name of my plasmoid <strong><em>a2n.blur</em></strong>.</p><p>Ok so far our file looks like this :</p><pre># Maintainer: Bouteiller a2n Alan &lt;a2n.dev@pm.me&gt;<br><br>_tag=123456789123456789<br>_sourceName=&quot;blurredwallpaper&quot;<br>_plasmoidName=&quot;a2n.blur&quot;<br><br>pkgname=&quot;kdeplasma-blurredwallpaper-git&quot;<br>pkgver=2.2.0<br>pkgrel=1<br>pkgdesc=&quot;KDE plasma wallpaper plugin that blur the wallpaper when a window is active&quot;<br>arch=(&quot;any&quot;)<br>url=&quot;https://github.com/bouteillerAlan/blurredwallpaper&quot;<br>license=(&quot;GPL3&quot;)<br>depends=()<br>makedepends=(git)<br>optdepends=()<br>source=(&quot;git+${url}.git#tag=${_tag}?signed&quot;)<br>md5sums=(&quot;SKIP&quot;)<br>validpgpkeys=(6A2ECC8A396F8A943A109A1E0F11C2A6BF79111E)<br><br>pkgver() {<br>  cd &quot;${_sourceName}&quot;<br>  git describe --tags | sed &#39;s/^v//&#39;<br>}<br><br>package() {<br>  cd &quot;${_sourceName}&quot;<br>  install -Dm 644 LICENSE -t &quot;${pkgdir}&quot;/usr/share/licenses/&quot;${pkgname}&quot;/<br>  mkdir -p &quot;${pkgdir}/usr/share/plasma/wallpapers/${_plasmoidName}&quot;<br>  install -Dm 644 metadata.json -t &quot;${pkgdir}&quot;/usr/share/plasma/wallpapers/&quot;${_plasmoidName}&quot;/<br>  find &quot;contents&quot; -type f -exec install -Dm 644 &quot;{}&quot; &quot;${pkgdir}/usr/share/plasma/wallpapers/${_plasmoidName}/{}&quot; \;<br>}</pre><h3>The real last step : quality check</h3><p>Before submitting, we have to ensure that our package and code is bulletproof with “quality assurance step”.</p><p>The first one is very simple, just run the <strong><em>makepkg</em></strong> command in your working directory. If this command fails, recheck your code. For me, no problem with this step.</p><p>For validating this step, you can check for :<br>- a file named <strong><em>pkgname-pkgver.pkg.tar.zst</em></strong> in the folder (this package can be installed with the <strong><em>pacman -U</em></strong> command)<br>- a rule of thumbs is to check if this package contains all the file and dependencies you want with <strong><em>pacman -Qlp [package file]</em></strong> and <strong><em>pacman -Qip [package file]</em></strong> commands</p><p>For example, my result :</p><pre>[a2n@a2n-eso dracut-numlock]$ pacman -Qlp kdeplasma-blurredwallpaper-git-2.2.0-1-any.pkg.tar.zst <br>dracut-numlock /usr/<br>dracut-numlock /usr/share/<br>dracut-numlock /usr/lib/licenses/<br>...</pre><p>After checking all that, we can use the <strong><em>namcap </em></strong>(is it pacman that’s upside down or nampac?) command to check the package sanity.</p><p>You can install it via the <strong><em>namcap</em></strong> package : <a href="https://archlinux.org/packages/extra/any/namcap/">https://archlinux.org/packages/extra/any/namcap/</a></p><p>This command check the <strong><em>PKGBUILD </em></strong>contents for common errors and package file hierarchy for unnecessary/misplaced files, then check if the <strong><em>depends </em></strong>options is well setup (in short, <a href="https://wiki.archlinux.org/title/Creating_packages#Checking_package_sanity">read the doc here</a>).</p><p>So we have to run :</p><pre>namcap PKGBUILD<br>namcap _&lt;package file name&gt;_.pkg.tar.zst</pre><p>In my case, I have no error or warning :)</p><p>If you want to test that command, you can remove the git dependency and rerun the namcap PKGBUILD command.</p><p>Another step you want to do before submitting the package is checking if all the files and directories present under the pkg directory (created by the makepkg command) are ok. This directory represents the actual result the user is going to have.</p><h3>Submitting the package</h3><p>First you need to add an <strong><em>ssh</em></strong> key to your account right there : <a href="https://aur.archlinux.org/account/[your-username]/edit">https://aur.archlinux.org/account/[your-username]/edit</a>.</p><p>You have to add a new line for this key in your ssh config file :</p><pre>Host aur.archlinux.org<br>  IdentityFile ~/.ssh/aur<br>  User aur</pre><p>The <strong><em>IdentityFile</em></strong> should correspond to your private key.</p><p>Next, we have to add the remote repository to our existing project :</p><pre>git remote add aur ssh://aur@aur.archlinux.org/kdeplasma-blurredwallpaper-git.git</pre><p>and then :</p><pre>git fetch aur</pre><p>Note that the aur works only with main branch that has been called <strong><em>master</em></strong>.</p><p>Now we need to generate the <strong><em>.SRCINFO</em></strong> file, commit it and then push it to the new remote <strong><em>aur</em></strong>.<br>We can do that with the following command :</p><pre>makepkg --printsrcinfo &gt; .SRCINFO</pre><p>And we can commit both of the file :</p><pre>git add .SRCINFO PKGBUILD<br>git commit -am &#39;add pkgbuild and srcinfo&#39;</pre><p>You have to make sure that the last commit have both file in it. If it’s not the case, the push is rejected by the AUR repository.</p><p>Ok, you are at the end of this tutorial, you just need to push your package with the following command :</p><pre>git push --set-upstream aur master</pre><h3>Checking if the submission is ok</h3><p>For that, nothing special to do, you just have to check your AUR home page. if the package is well submitted, the package is shown on your list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*WrL42HKA0yA6nkNRaPNOMw.png" /></figure><p>You can run an install, with yay for example, if you want to try your new package :</p><pre>yay -S kdeplasma-blurredwallpaper-git</pre><p>That’s all folks, thanks for reading :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4133f86e98c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neovim config from scratch]]></title>
            <link>https://a2nb.medium.com/neovim-config-from-scratch-1ea808b4d44c?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ea808b4d44c</guid>
            <category><![CDATA[nvim]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[neovim]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Tue, 24 Oct 2023 17:22:16 GMT</pubDate>
            <atom:updated>2023-10-24T17:22:16.807Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dLZpw6DXNo4YnsQrAdWjIw.png" /></figure><p><a href="https://youtu.be/BRFmb7UudyU">Check out the YouTube video too !</a></p><p>So you want to pimp your neovim ? I’ve erased mine to show you how to do it, so let’s go !</p><h3>Basics</h3><p>So we go into the <strong><em>.config</em></strong> folder and create the <strong><em>nvim</em></strong><em> </em>folder.<br>Then we create an <strong><em>init.lua</em></strong>, that is the first file loaded by nvim.<br>After that we add a folder called <strong><em>lua</em></strong><em> </em>then, in it, a folder called <strong><em>a2n</em></strong>.<br>Each folder present on the <strong><em>lua</em></strong><em> </em>folder is callable with lua.</p><p>For example, if we put a print in the first init file then create a second init file in the a2n folder, with a print too we have both of the print showed when we launch nvim.</p><p>So far we have done that :</p><pre>➜ tree<br>.<br>├── init.lua<br>└── lua<br> └── a2n<br> └── init.lua</pre><p>In the first <strong><em>init.lua,</em></strong> add the following line for loading the <strong><em>init.lua</em></strong> file created in the <strong><em>lua/a2n</em></strong> folder :</p><pre>require(&quot;a2n&quot;)</pre><p>Now, how to install plugins ?<br>For that we are going to use <a href="https://github.com/wbthomason/packer.nvim?tab=readme-ov-file#quickstart">packer</a>, a plugin manager.</p><p>You just have to run the following command in your terminal for installing it :</p><pre>git clone - depth 1 https://github.com/wbthomason/packer.nvim\<br> ~/.local/share/nvim/site/pack/packer/start/packer.nvim</pre><p>Then we create a file named <strong><em>packer.lua</em></strong> in the <strong><em>a2n</em></strong> folder.<br>And we add the following code in it :</p><pre>vim.cmd [[packadd packer.nvim]]<br>return require(&#39;packer&#39;).startup(function(use)<br> use &#39;wbthomason/packer.nvim&#39;<br>end)</pre><p>Then we can close neovim, add the following line in the <strong><em>init.lua</em></strong> file from the <strong><em>a2n </em></strong>folder :</p><pre>require(&quot;a2n.packer&quot;)</pre><p>Save and type <strong><em>PackerSync</em></strong>. And voilà Packer is set up!</p><h3>Telescope</h3><p>Now let’s go with <a href="https://github.com/nvim-telescope/telescope.nvim?tab=readme-ov-file#installation">Telescope</a>. Telescope is a fuzzy finder, it means that this plugin gives us the ability to navigate and search files and folders.</p><p>We just have to add the following line to our <strong><em>packer.lua</em></strong> file :</p><pre>use {<br> &#39;nvim-telescope/telescope.nvim&#39;, tag = &#39;0.1.4&#39;, requires = { {&#39;nvim-lua/plenary.nvim&#39;} }<br>}</pre><p>Pro tips : hit the <strong><em>= </em></strong>key<strong><em> </em></strong>if you want to indent correctly the line you have selected with <strong><em>v</em></strong>.</p><p>And then <strong><em>PackerSync</em></strong>.</p><p>Now we create a directory called <strong><em>after </em></strong>in the root of our config, and next we create a directory named <strong><em>plugin</em></strong> in it.</p><p>You should have something like that :</p><pre>.<br>├── after<br>│ └── plugin<br>├── init.lua<br>├── lua<br>│ └── a2n<br>│ ├── init.lua<br>│ └── packer.lua<br>└── plugin<br> └── packer_compiled.lua</pre><p>Now we create a file named <strong><em>telescope.lua</em></strong> in this folder. Next go to the telescope repository and grab the first two lines of the config <a href="https://github.com/nvim-telescope/telescope.nvim?tab=readme-ov-file#usage">right there</a> and add it to the file :</p><pre>local builtin = require(&#39;telescope.builtin&#39;)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;leader&gt;ff&#39;, builtin.find_files, {})</pre><p>If you want, you can change the shortcut, for example if you want to replace <strong><em>ff</em></strong> with <strong><em>sf</em></strong> :</p><pre>vim.keymap.set(&#39;n&#39;, &#39;&lt;leader&gt;pf&#39;, builtin.find_files, {})</pre><p>Telescope is packed with a lot of <a href="https://github.com/nvim-telescope/telescope.nvim?tab=readme-ov-file#pickers">built-in finders</a> so, for example, we can only search git file by adding the following shortcut (<em>lead+f+g</em>):</p><pre>vim.keymap.set(&#39;n&#39;, &#39;&lt;leader&gt;fg&#39;, builtin.git_files, {})</pre><h3>Remaps key</h3><p>By default, the leader key is the backslash and I don’t want this key, I want the <strong><em>space </em></strong>key (the super key is not recognized by most of the terminal this is why I use <strong><em>space</em></strong>).<br>For that we are going to create a file named <strong><em>remap.lua</em></strong> in the <strong><em>a2n </em></strong>folder.</p><p>And we add the following line :</p><pre>vim.g.mapleader = &quot; &quot;</pre><p>Then save and reopen neovim and hit <strong><em>space+f+f</em></strong> and voila !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0FnJwinzQASCBW-gxjPuPA.png" /><figcaption>Telescope find files in action</figcaption></figure><h3>Treesitter</h3><p>Now the blazing fast plugin : <a href="https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file">treesitter</a>. This stuff parse your code like Flash (the superhero not the dead language) and build an incremental tree for each change you do, in live. That gives you as a result to have highlighting and indenting for example.</p><p>If you want to use it (don’t be that guy, use it) you just have to add this line to the <strong><em>packer.lua</em></strong> file :</p><pre>use { &#39;nvim-treesitter/nvim-treesitter&#39;, run = &#39;:TSUpdate&#39; }</pre><p>You can have an error here with the <strong><em>TSUpdate</em></strong> command. This is a known bug. But it will run correctly when updating, so we can add the following code to avoid that (in place of the <strong><em>TSUpdate</em></strong>) :</p><pre>run = function()<br> local ts_update = require(&#39;nvim-treesitter.install&#39;).update({ with_sync = true })<br> ts_update()<br> end,</pre><p>Or you can just call <strong><em>PackerUpdate</em></strong>.</p><p>Now we have to initialize treesitter. And you guess well, let’s create a file under the <strong><em>plugin</em></strong> folder called <strong><em>treesitter.lua</em></strong>.</p><p>Then add <a href="https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#modules">the example config</a> found on the repo in it, remove all the comments if you want, do the same with the options you don’t want, add some language in the required parser, then boom a clean config file :</p><pre>require&#39;nvim-treesitter.configs&#39;.setup {<br> ensure_installed = { &quot;rust&quot;, &quot;javascript&quot;, &quot;typescript&quot;, &quot;c&quot;, &quot;lua&quot;, &quot;vim&quot;, &quot;vimdoc&quot;, &quot;query&quot; },<br> sync_install = false,<br> auto_install = true,<br>highlight = {<br> enable = true,<br> additional_vim_regex_highlighting = false,<br> },<br>}</pre><p>Write the file then exit and re-open it, and if everything is set up correctly you may view at the bottom treesitter downloading all the parser we have put on the option key.</p><p>Now you may have colorization like so :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q6Bxlsvj3xwfzekHX1Cauw.png" /><figcaption>Colorization via the lua parser</figcaption></figure><h3>Fugitive</h3><p>Fugitive gives us the possibility to do a lot of stuff with git. For example, if you want to check the blame you have to do a <strong><em>:Git blame</em></strong> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WIqNhQ4DLhfDk8kjdHZ6Cg.png" /><figcaption>Git blame with fugitive</figcaption></figure><p>The same install process is applied here : <br>- add the <strong><em>use</em></strong> line to the <strong><em>packer.lua</em></strong> file<br>- write and close the file<br>- reopen neovim and do a <strong><em>PackerSync</em></strong><br>- create shortcut for the command you want to use :)</p><p>If you want to have inline blame you can use the following plugin : <a href="https://github.com/lewis6991/gitsigns.nvim">lewis6991/gitsigns.nvim</a>.</p><p>I’m stopping there for the plugin because you have to check what kind of plugin you want among the huge choice available out there :)<br>If you want some ideas I have put at the end of this article a little list of plugins I used.</p><h3>The LSP</h3><p>The LSP is the heart of our setup, especially if your plan is to use neovim for coding :)<br>This is the stuff that gives you auto-completion on context based on the current language or framework your working with.</p><p>First I want to install <strong><em>j-hui/fidget.nvim</em></strong> because it gives a little but practical information : is the current buffer loading a lsp ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*XwBwbEH-vDUBYiIh9m2p8g.png" /><figcaption>rust lsp on launch</figcaption></figure><p>As always we add a <strong><em>use</em></strong> line on our <strong><em>plugin.lua</em></strong> file like so :</p><pre>use { &#39;j-hui/fidget.nvim&#39;, tag = &#39;legacy&#39; }</pre><p>After a reload and a <strong><em>PackerSync</em></strong> we create the now well-known, config file (named <strong><em>fidget.lua</em></strong>) under <strong><em>after/plugin</em></strong> and call the main function :</p><pre>require(&#39;fidget&#39;).setup {}</pre><p>Ok now the lsp in itself !<br>We are going to use <strong><em>lsp-zero</em></strong> for that. Let’s copy the code available on the repo <a href="https://github.com/VonHeikemen/lsp-zero.nvim?tab=readme-ov-file#installing">right there</a> and paste it on the packer file, like always. Uncomment the two first lines and voilà :</p><pre>use {<br> &#39;VonHeikemen/lsp-zero.nvim&#39;,<br> branch = &#39;v3.x&#39;,<br> requires = {<br> - manage LSP from neovim<br> {&#39;williamboman/mason.nvim&#39;},<br> {&#39;williamboman/mason-lspconfig.nvim&#39;},<br> - LSP Support<br> {&#39;neovim/nvim-lspconfig&#39;},<br> <br> - Autocompletion<br> {&#39;hrsh7th/nvim-cmp&#39;},<br> {&#39;hrsh7th/cmp-nvim-lsp&#39;},<br> {&#39;L3MON4D3/LuaSnip&#39;},<br> }<br>}</pre><p>Reload, do <strong><em>PackerSync </em></strong>and then create a file named <strong><em>lsp.lua</em></strong> under the <strong><em>after/plugin</em></strong> directory.</p><p>Ok, now we copy and paste <a href="https://github.com/VonHeikemen/lsp-zero.nvim?tab=readme-ov-file#usage">the following code</a> into our config file. That allows lsp-zero to load his shortcuts only if a lsp is active on the current buffer.<br>This is very handy because we can create a shortcut that uses <strong><em>gd</em></strong> only if a lsp is present and, on the other case, uses the same shortcut for something else.</p><pre>local lsp_zero = require(&#39;lsp-zero&#39;)<br>lsp_zero.on_attach(function(client, bufnr)<br> lsp_zero.default_keymaps({buffer = bufnr})<br>end)</pre><p>Now we have two options for handling the server we want to install on our setup :<br>- you dl the lsp you want via the information provided by <a href="https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md">this page</a> and add the init function of each lsp into the <strong><em>lsp.lua</em></strong> file<br>- you use the <strong><em>mason</em></strong> plugin that allows you to automatically handle the lsp you want via lsp-zero</p><p>I’m gonna fit with mason because I love to have automatic setup, especially on lsp that is a kind of boring stuff when it’s installed manually.</p><p>The two packages we need (mason and mason-lspconfig) are already loaded in our config (remember the two lines we have un-commented).</p><p>Next, we just have to implement it into the config file of lsp-zero like so :</p><pre>require(&#39;mason&#39;).setup({})<br>require(&#39;mason-lspconfig&#39;).setup({<br> ensure_installed = {&#39;tsserver&#39;, &#39;rust_analyzer&#39;},<br> handlers = {<br> lsp_zero.default_setup,<br> },<br>})</pre><p>Here we have this line <strong><em>lsp_zero.default_setup</em></strong> that automatically handle the config for us.<br>And in the <strong><em>ensure_installed</em></strong> key we can put all the lsp we want from <a href="https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers">this list</a>.</p><p>For example with Lua we add <strong><em>lua_ls</em></strong>, write and close the file then reopen neovim and tada! :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*y27F95QMU-YfJM_KPTrmJA.png" /><figcaption>Autocomplete !</figcaption></figure><p>You can also use directly the <strong><em>Mason </em></strong>command for doing so but keep in mind that this solution doesn’t add the lsp name to this list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbNnqgkm6zxyZCubsFjTiQ.png" /><figcaption>LSP auto install with mason</figcaption></figure><p>In the same way keep in mind that certain lsp need certain prerequisite, for example the lsp for html, css and javascript need to have npm so you have to install it.</p><p>You have all the default shortcut right there : <a href="https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/api-reference.md#lsp-actions">https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/api-reference.md#lsp-actions</a>.</p><p>Finally I’m going to change the default icon showed in the gutter via this config :</p><pre>lsp_zero.set_sign_icons({<br> error = &#39;✘&#39;,<br> warn = &#39;▲&#39;,<br> hint = &#39;⚑&#39;,<br> info = &#39;»&#39;<br>})</pre><h3>Final setup</h3><p>Ok, now I just have to do one or two things for having neovim like I love. For example, I don’t have any line number.</p><p>For that we have to create another config file under <strong><em>lua/a2n</em></strong>, in general call it <strong><em>base.lua</em></strong> and we need to load it via the <strong><em>init.lua</em></strong> from <strong><em>lua/a2n</em></strong>.</p><p>So I add the <strong><em>require </em></strong>line in the <strong><em>init.lua</em></strong> file :</p><pre>require(&quot;a2n.base&quot;)</pre><p>And now I add the following settings to the <strong><em>base.lua</em></strong> file :</p><pre>- NEOVIM<br>vim.opt.termguicolors = true - enabled 24bit RGB color<br>vim.opt.signcolumn = &#39;yes&#39; - always draw the sign column<br>vim.opt.updatetime = 50 - update time for the swap file and for the cursorHold event<br>vim.opt.colorcolumn = &#39;80&#39; - colorized the 80th column<br>vim.opt.clipboard:append { &#39;unnamedplus&#39; } - force to use the clipboard for all the operations<br> - BACKUP<br>vim.opt.backup = false - no backup of the current file is made<br> - FILE LINES<br>vim.wo.number = true - show line number<br>vim.wo.relativenumber = true - set line number format to relative<br>vim.opt.wrap = false - wrap lines<br>vim.opt.scrolloff = 8 - min nb of line around your cursor (8 above, 8 below)<br> - INDENT<br>vim.opt.smartindent = true - try to be smart w/ indent<br>vim.opt.autoindent = true - indent new line the same amount as the line before<br>vim.opt.shiftwidth = 2 - width for autoindents<br> - TAB<br>vim.opt.expandtab = true - converts tabs to white space<br>vim.opt.tabstop = 2 - nb of space for a tab in the file<br>vim.opt.softtabstop = 2 - nb of space for a tab in editing operations<br> - SEARCH<br>vim.opt.ignorecase = true - case insensitive UNLESS /C or capital in search<br>vim.opt.hlsearch = true - highlight all the result found<br>vim.opt.incsearch = true - incremental search (show result on live)<br>vim.opt.wildignore:append { &#39;*/node_modules/*&#39;, &#39;*/vendor/*&#39; } - the search ignore this folder<br> - CONTEXTUAL<br>vim.opt.title = true - set the title of the window automaticaly, usefull for tabs plugin<br>vim.opt.path:append { &#39;**&#39; } - search (gf or :find) files down into subfolders</pre><h3>If you don’t want backup but undotree</h3><p>By default, neovim use a backup file for each buffer that you open.<br>Another option you want to use, more familiar, especially if you use git, is the `undotree` plugin.</p><p>We just have to install it via packer, as always :</p><pre>- in packer.lua<br>use &#39;mbbill/undotree&#39;</pre><p>And you have to set some options in the <strong><em>base.lua</em></strong> file too :</p><pre>vim.opt.swapfile = false - disable the default backup behavior<br>vim.opt.backup = false - disable the default backup behavior<br>vim.opt.undofile = true - activate the undofile behavior<br>vim.opt.undodir = os.getenv(&#39;HOME&#39;) .. &#39;/.vim/undodir&#39; - use the directory of undotree plugin for managing the history</pre><p>With that you can view the undo tree created by neovim :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vL9VReRbR8U8YYMH2PUBmg.png" /><figcaption>Undotree</figcaption></figure><p>And you can navigate the history like in git ! This is very powerful.</p><p>We also can add the shortcut via a config file :</p><pre>vim.keymap.set(&#39;n&#39;, &#39;&lt;leader&gt;&lt;F5&gt;&#39;, vim.cmd.UndotreeToggle)</pre><h3>Theme</h3><p>Okai, for the end of this tutorial a little bit of art, because we all love an eyes candy setup !</p><p>I’m going to use the catppuccin theme, you have the repo for neovim <a href="https://github.com/catppuccin/nvim">just here</a>.</p><p>We install it like any other plugin : <strong><em>use { ‘catppuccin/nvim’, as = ‘catppuccin’ }</em></strong>.<br>Don’t forget to do <strong><em>PackerSync</em></strong>.</p><p>And then we create the config file (as always in <strong><em>after/plugin</em></strong>), the file is called <strong><em>catppuccin.lua</em></strong> :</p><pre>require(&#39;catppuccin&#39;).setup({<br> flavour = &#39;mocha&#39;<br>})<br>vim.cmd.colorscheme &#39;catppuccin&#39;</pre><p>And voilà :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*1WCIH5Ojj2WLiz-FIeyE_A.png" /><figcaption>Tada 🥳</figcaption></figure><p>That’s all folks, thanks for reading :)</p><p>List of plugins I use or have used :</p><pre>use &#39;wbthomason/packer.nvim&#39;<br>use { &#39;catppuccin/nvim&#39;, as = &#39;catppuccin&#39; } -- theme<br>use &#39;nvim-lualine/lualine.nvim&#39; -- statusline<br>use &#39;nvim-lua/plenary.nvim&#39; -- common utilities<br>use &#39;onsails/lspkind-nvim&#39; -- vscode-like pictograms<br>use &#39;hrsh7th/cmp-buffer&#39; -- nvim-cmp source for buffer words<br>use &#39;hrsh7th/cmp-nvim-lsp&#39; -- nvim-cmp source for neovim built-in LSP<br>use &#39;hrsh7th/nvim-cmp&#39; -- auto completion<br>use &#39;neovim/nvim-lspconfig&#39; -- LSP<br>use &#39;jose-elias-alvarez/null-ls.nvim&#39; -- use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua<br>use &#39;MunifTanjim/prettier.nvim&#39; -- prettier plugin for Neovim built-in LSP client<br>use &#39;williamboman/mason.nvim&#39; -- lsp auto handler<br>use &#39;williamboman/mason-lspconfig.nvim&#39; -- lsp auto handler<br>use &#39;glepnir/lspsaga.nvim&#39; -- LSP UIs<br>use &#39;L3MON4D3/LuaSnip&#39; -- Snippet Engine<br>use { &#39;nvim-treesitter/nvim-treesitter&#39;, run = &#39;:TSUpdate&#39; }<br>use &#39;kyazdani42/nvim-web-devicons&#39; -- file icons<br>use &#39;nvim-telescope/telescope.nvim&#39; -- file browser<br>use &#39;nvim-telescope/telescope-file-browser.nvim&#39; -- file browser<br>use &#39;nvim-lua/popup.nvim&#39;<br>use {&#39;nvim-telescope/telescope-fzf-native.nvim&#39;, run = &#39;make&#39; } -- fzf in telescope<br>use &#39;windwp/nvim-autopairs&#39; -- auto pairs for general symbol<br>use &#39;windwp/nvim-ts-autotag&#39; -- auto tag for ts <br>use &#39;norcalli/nvim-colorizer.lua&#39; -- give the real color under the css value<br>use &#39;folke/zen-mode.nvim&#39;<br>use({ &quot;iamcco/markdown-preview.nvim&quot;, run = function() vim.fn[&quot;mkdp#util#install&quot;]() end, })<br>use {&#39;akinsho/bufferline.nvim&#39;, tag = &quot;v2.*&quot;, requires = &#39;kyazdani42/nvim-web-devicons&#39;}<br>use &#39;lewis6991/gitsigns.nvim&#39; -- git blame inline<br>use &#39;dinhhuy258/git.nvim&#39; -- For git blame &amp; browse<br>use &#39;goolord/alpha-nvim&#39; -- dashboard greeter<br>use &#39;j-hui/fidget.nvim&#39; -- workspace lsp status</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ea808b4d44c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Submitting a package to the AUR]]></title>
            <link>https://a2nb.medium.com/submitting-a-package-to-the-aur-e9117d07494d?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9117d07494d</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[arch]]></category>
            <category><![CDATA[arch-linux]]></category>
            <category><![CDATA[package]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Fri, 20 Oct 2023 08:30:19 GMT</pubDate>
            <atom:updated>2023-10-20T08:30:19.843Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b7DyHPZyeA76gM_uI1RsXw.png" /><figcaption>AUR homepage</figcaption></figure><p>This is a little story about my research to publish for the first time a package to the AUR.</p><p>Summary :</p><ul><li>Context and some thoughts</li><li>Research and experimentation</li><li>Writing bad code</li><li>Writing good code &amp; connecting the dot</li><li>Quality check</li><li>Submitting the package</li><li>Final thoughts about the errors I made &amp; the tools I used</li></ul><h4>🧑‍🏭 Context and some thought</h4><p>This is a little story about my research to publish for the first time a package to the AUR.<br>I struggle a little to understand some concept but with some time, help, and re-reading the wiki I made my way into it.</p><p>You can use this story for a tutorial purpose but keep in mind that it wasn’t written for that.</p><p>IMO the wiki is well written, but it also lacks of example in parallel. And sometime a simple tutorial in addition to a more complete documentation is a more powerful tool than having to read other developers’ code (which is not often commented on, by the way) and trying to understand what the wiki says in parallel.</p><p>But that’s a discussion for later, so, let’s back to the story.</p><h4>🕵️ Research and experimentation</h4><p>Because I use “dracut numlock” on my Arch Linux, and it is not available on the AUR or on the official repo, I wanted to push it myself. I have never done that so let&#39;s go for a new adventure !</p><p>So, first thing first, I read the documentation available in the Arch Linux wiki (<a href="https://wiki.archlinux.org/title/AUR_submission_guidelines">https://wiki.archlinux.org/title/AUR_submission_guidelines</a>) :</p><ul><li>I have searched in the official repo and in the AUR if a package called “dracut numlock” is found and nothing pop-out</li><li>I think this may be useful to have this code in the AUR for a more automated installation alongside other project when user setup their Arch Linux</li></ul><p>The first step is pretty simple, I create a fork of the actual repository via the GitHub interface and clone it.</p><p>Next to that, I read <a href="https://wiki.archlinux.org/title/Arch_package_guidelines">the package guidelines</a> and <a href="https://wiki.archlinux.org/title/Creating_packages">the “creating packages” page</a> that is a kind of tutorial provided by the wiki.</p><p>After some reading, I found interesting to cote a line in the makepkg man page :</p><blockquote>The advantage to a script-based build is that the work is only done once. Once you have the build script for a package, _makepkg_ will do the rest: download and validate source files, check dependencies, configure the build-time settings, build the package, install the package into a temporary root, make customizations, generate meta-info, and package the whole thing up for pacman to use.</blockquote><p>This is interesting because it seems to say that the build of a package for the AUR is nothing more than a PKGBUILD file.</p><p>So I used the default one given by the wiki, example exist too under the <strong>/usr/share/pacman</strong> file. With the aid of the PKGBUILD man page, I’have written that file :</p><pre># Maintainer: Bouteiller a2n Alan &lt;a2n.dev@pm.me&gt;<br>pkgname=dracut-numlock<br>pkgver=1.0.0<br>pkgrel=1<br>pkgdesc=&quot;A dracut module which enables numlock in the early boot&quot;<br>arch=(&#39;any&#39;)<br>url=&quot;https://github.com/bouteillerAlan/dracut-numlock/tree/v1.0.0&quot;<br>license=(&#39;MIT&#39;)<br>source=(&quot;https://github.com/bouteillerAlan/$pkgname/archive/refs/tags/v$pkgver.tar.gz&quot;)<br><br>prepare() {<br>    echo &quot;prepare&quot;<br>}<br><br>build() {<br> echo &quot;build&quot;<br>}<br><br>check() {<br> echo &quot;check&quot;<br>}<br><br>package() {<br> echo &quot;package&quot;<br>}</pre><p>Next to that I launch the <strong>makepkg </strong>command for testing the file directly in the folder, this has the effect to download the tar.gz file provided by GitHub. But I also have an error now :</p><pre>==&gt; ERROR: Integrity checks are missing for: source</pre><p>With the reading of the PKGBUILD man page in the <strong>cksums </strong>section, I resolve the problem :</p><ul><li>we run this next command : <strong>makepkg -g &gt;&gt; PKGBUILD</strong></li></ul><p>This has the effect of adding a line in our PKGBUILD file that represent the checksum of our tar.gz. If you put another source in the source keyword, the command generates the checksum for that source, in order if multiple source is present, automatically.</p><p>I re-run the <strong>makepkg </strong>command and, voilà, no error message :</p><pre>󰣇 makepkg               <br>==&gt; Making package: dracut-numlock 1.0.0-1 (Sat 09 Sep 2023 18:19:12 CEST)<br>==&gt; Checking runtime dependencies...<br>==&gt; Checking buildtime dependencies...<br>==&gt; Retrieving sources...<br>  -&gt; Found v1.0.0.tar.gz<br>==&gt; Validating source files with sha256sums...<br>    v1.0.0.tar.gz ... Passed<br>==&gt; Extracting sources...<br>  -&gt; Extracting v1.0.0.tar.gz with bsdtar<br>==&gt; Starting prepare()...<br>prepare<br>==&gt; Starting build()...<br>build<br>==&gt; Starting check()...<br>check<br>==&gt; Entering fakeroot environment...<br>==&gt; Starting package()...<br>package<br>==&gt; Tidying install...<br>  -&gt; Removing libtool files...<br>  -&gt; Purging unwanted files...<br>  -&gt; Removing static library files...<br>  -&gt; Stripping unneeded symbols from binaries and libraries...<br>  -&gt; Compressing man and info pages...<br>==&gt; Checking for packaging issues...<br>==&gt; Creating package &quot;dracut-numlock&quot;...<br>  -&gt; Generating .PKGINFO file...<br>  -&gt; Generating .BUILDINFO file...<br>  -&gt; Generating .MTREE file...<br>  -&gt; Compressing package...<br>==&gt; Leaving fakeroot environment.<br>==&gt; Finished making: dracut-numlock 1.0.0-1 (Sat 09 Sep 2023 18:19:14 CEST)</pre><p>Here we have our 4 commands :</p><ul><li>prepare()</li><li>build()</li><li>check()</li><li>package()</li></ul><h4>🥶 Writing bad code</h4><p>Now I need to implement the right code for each command, only if the command is useful, so I think I just need the mandatory <strong>package()</strong> function.</p><p>I write the next code for this function :</p><pre>package() {<br> echo &quot;running package&quot;<br> cd &quot;$pkgname-$pkgver&quot;<br> sudo cp -r 50numlock/ /home/a2n/PhpstormProjects/xxxx/<br> sudo dracut -f<br>}</pre><p>I have created the temporary file <strong>xxxx </strong>for testing purpose.<br>The <strong>50numlock </strong>folder are well copied and the dracut command well launch.</p><p>So the final code is the following for this function :</p><pre>package() {<br> cd &quot;$pkgname-$pkgver&quot;<br> sudo cp -r 50numlock/ /usr/lib/dracut/modules.d/<br> sudo dracut -f<br>}</pre><p>But we have another error :</p><pre>ERROR: ld.so: object &#39;libfakeroot.so&#39; from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.</pre><p>After some research, I found <a href="https://www.reddit.com/r/archlinux/comments/boojv8/first_time_publishing_an_aur_package/">a post on Reddit</a> where <a href="https://www.reddit.com/r/archlinux/comments/boojv8/comment/eniqkzx/?utm_source=share&amp;utm_medium=web2x&amp;context=3">a user said</a> :</p><blockquote>— Use <strong>install </strong>instead of <strong>cp </strong>and <strong>mkdir</strong></blockquote><p>Another research tells me that I don’t have to use <strong>sudo</strong> or any of post install commands like <strong>dracut-rebuild</strong> on PKGBUILD.</p><p>So I promptly check the man page of <strong>install </strong>and read on it :</p><blockquote>This install program copies files (often just compiled) into destination locations you choose.</blockquote><p>Yeah. Right… <br>So my code is not good at all ^^</p><h4>👏 Writing good code &amp; connecting the dot</h4><p>So I edited the code like that :</p><pre>package() {<br> cd &quot;$pkgname-$pkgver&quot;<br> install -Dm 644 50numlock/module-setup.sh &quot;${pkgdir}&quot;/usr/lib/dracut/modules.d/50numlock/module-setup.sh<br> install -Dm 644 50numlock/numlock.sh &quot;${pkgdir}&quot;/usr/lib/dracut/modules.d/50numlock/numlock.sh<br>}</pre><p>Here the <strong>-D</strong> flag creates all leading components of the destination except the last one, then it copies the source to the destination.</p><p>The <strong>$pkgdir</strong> variable represents a temporary folder where the package put its files during the <strong>package</strong> or the <strong>build</strong> process.</p><p>Afterward a <strong>.MTREE</strong> file is generated (among other), this contains all the metadata of the files that are needed to be installed by the package. Then <strong>pacman</strong> takes care of the installation step.</p><h4>🧑‍💼 Quality check</h4><p>Before submitting, we have to ensure that our package and code is bulletproof with “quality assurance step”.</p><p>The first one is very simple, just run the <strong>makepkg </strong>command in your working directory. If this command fails, recheck your code. For me, no problem with this step.</p><p>For validating this step, you can check for :</p><ul><li>a file named <strong>pkgname-pkgver.pkg.tar.zst</strong> in the folder (this package can be installed with the <strong>pacman -U</strong> command)</li><li>a rule of thumbs is to check if this package contains all the file and dependencies you want with <strong>pacman -Qlp [package file]</strong> and <strong>pacman -Qip [package file]</strong> commands</li></ul><p>For example, my result :</p><pre>[a2n@a2n-eso dracut-numlock]$ pacman -Qlp dracut-numlock-1.0.0-1-any.pkg.tar.zst <br>dracut-numlock /usr/<br>dracut-numlock /usr/lib/<br>dracut-numlock /usr/lib/dracut/<br>dracut-numlock /usr/lib/dracut/modules.d/<br>dracut-numlock /usr/lib/dracut/modules.d/50numlock/<br>dracut-numlock /usr/lib/dracut/modules.d/50numlock/module-setup.sh<br>dracut-numlock /usr/lib/dracut/modules.d/50numlock/numlock.sh</pre><p>After checking all that we can use the <strong>namcap </strong>(is it pacman that’s upside down or nampac?) command to check the package sanity.</p><p>You can install it via the <strong>namcap </strong>package : <a href="https://archlinux.org/packages/extra/any/namcap/">https://archlinux.org/packages/extra/any/namcap/</a></p><p>This command checks the <strong>PKGBUILD</strong> contents for common errors and package file hierarchy for unnecessary/misplaced files, then check if the <strong>depends </strong>option is well setup (in short, <a href="https://wiki.archlinux.org/title/Creating_packages#Checking_package_sanity">read the doc here</a>).</p><p>So we have to run :</p><pre>namcap PKGBUILD<br>namcap _&lt;package file name&gt;_.pkg.tar.zst</pre><p>In my case, I have the following error / warning :</p><pre>[a2n@a2n-eso dracut-numlock]$ namcap PKGBUILD <br>PKGBUILD (dracut-numlock) W: Non-unique source name (v1.0.0.tar.gz). Use a unique filename.</pre><p>So for patching that I updated the source to the following :</p><pre>source=(&quot;https://github.com/bouteillerAlan/${pkgname}/releases/download/${pkgname}-v${pkgver}/${pkgname}-v${pkgver}.tar.gz&quot;)</pre><p>With that I have to create <a href="https://github.com/bouteillerAlan/dracut-numlock/releases/tag/dracut-numlock-v1.0.1">a new release on GitHub</a> and re-run the <strong>makepkg -g &gt;&gt; PKGBUILD</strong> command for the checksum.</p><p>And the warning is gone ! :)</p><p>Now the final check is <strong>namcap _&lt;package file name&gt;_.pkg.tar.zst</strong> :</p><pre>[a2n@a2n-eso dracut-numlock]$ namcap dracut-numlock-1.0.1-1-any.pkg.tar.zst <br>dracut-numlock E: Missing custom license directory (usr/share/licenses/dracut-numlock)<br>dracut-numlock E: Dependency bash detected and not included (programs [&#39;sh&#39;] needed in scripts [&#39;usr/lib/dracut/modules.d/50numlock/module-setup.sh&#39;, &#39;usr/lib/dracut/modules.d/50numlock/numlock.sh&#39;])</pre><p>For the first one, we have to add the license of our package to the <strong>/usr/share/licenses</strong> folder. For that we have to add the following line to our <strong>package </strong>function :</p><pre>install -D LICENSE &quot;${pkgdir}&quot;/usr/share/licenses/&quot;${pkgname}&quot;/LICENSE</pre><p>The second error is fixed by updating the <strong>depends </strong>key like so :</p><pre>depends=(&quot;sh&quot;)</pre><p>And voilà, no error or warning :</p><pre>[a2n@a2n-eso dracut-numlock]$ makepkg -f<br>==&gt; Making package: dracut-numlock 1.0.1-1 (Sun 15 Oct 2023 05:10:54 PM CEST)<br># ....<br>==&gt; Finished making: dracut-numlock 1.0.1-1 (Sun 15 Oct 2023 05:10:55 PM CEST)<br>[a2n@a2n-eso dracut-numlock]$ namcap PKGBUILD <br>[a2n@a2n-eso dracut-numlock]$ namcap dracut-numlock-1.0.1-1-any.pkg.tar.zst <br>[a2n@a2n-eso dracut-numlock]$</pre><h4>🛫 Submitting the package</h4><p>Firstly, you need to add an <strong>ssh </strong>key to your account right there : <a href="https://aur.archlinux.org/account/[your-username]/edit">https://aur.archlinux.org/account/[your-username]/edit</a>.</p><p>You have to add a new line for this key in your ssh config file too :</p><pre>Host aur.archlinux.org<br>  IdentityFile ~/.ssh/aur<br>  User aur</pre><p>The <strong>IdentityFile </strong>should correspond to your private key.</p><p>Next, we have to add the remote repository to our existing project :</p><pre>git remote add aur ssh://aur@aur.archlinux.org/dracut-numlock.git</pre><p>and then :</p><pre>git fetch aur</pre><p>Note that the AUR works only with main branch that has been called <strong>master</strong>.</p><p>Now we need to generate the <strong>.SRCINFO</strong> file, commit it and then push it to the new remote <strong>aur</strong>.<br>We can do that with the following command :</p><pre>makepkg --printsrcinfo &gt; .SRCINFO<br>git add .SRCINFO PKGBUILD<br>git commit -m &quot;generate SRCINFO&quot;<br>git push</pre><p>You have to make sure that the last commit have both file in it. If it’s not the case, the push is rejected by the aur repository.</p><p>Here I encounter another problem, the aur repository keeps checking on the first commit of the branch if a PKGBUILD is included.</p><pre>remote: error: The following error occurred when parsing commit<br>remote: error: 653df83092b3079a445c6fce3dc19b97a56e7014:<br>remote: error: missing PKGBUILD</pre><p>For me that is not the case because the first commit have been made by the author of the module.</p><pre>commit 653df83092b3079a445c6fce3dc19b97a56e7014<br>Author: FivEawE &lt;fiveawe@gmail.com&gt;<br>Date:   Mon Dec 27 14:41:03 2021 +0100<br><br>    Initial commit</pre><p>So I need to find a way around that.</p><p>For that I have created another branch called <strong>historical-master</strong>, just for keeping all the commit history. Next, I have change is remote and push that to my repository :</p><pre>[a2n@a2n-eso dracut-numlock]$ git branch --move historical-master<br><br>[a2n@a2n-eso dracut-numlock]$ git branch -vv<br>* historical-master 5a05247 [origin/master] push to the aur<br>  main              8b99fd9 [origin/main] add usefull doc files<br><br>[a2n@a2n-eso dracut-numlock]$ git push -u origin historical-master<br>## .......<br>branch &#39;historical-master&#39; set up to track &#39;origin/historical-master&#39;.<br><br>[a2n@a2n-eso dracut-numlock]$ git branch -vv<br>* historical-master 5a05247 [origin/historical-master] push to the aur<br>  main              8b99fd9 [origin/main] add usefull doc files</pre><p>Finally, I checkout to the master branch and re-set the upstream branch :</p><pre>git push --set-upstream origin master</pre><p>And then made a squash with all the commit : <strong>git rebase -i HEAD~9</strong>.</p><p>At this step, I’m left with my last commit and the root commit.</p><p>For squashing them, you need to use this command : <strong>git rebase -i — root master</strong> (<a href="https://stackoverflow.com/questions/598672/squash-the-first-two-commits-in-git">source</a>).</p><p>That give me a master branch with only one commit containing all the other change :</p><pre>[a2n@a2n-eso dracut-numlock]$ git log<br>commit bde54a4e4999b5e52568accd75b1e7445c003e7b (HEAD -&gt; master, origin/master, origin/HEAD, aur/master)<br>Author: FivEawE &lt;fiveawe@gmail.com&gt;<br>Date:   Mon Dec 27 14:41:03 2021 +0100<br><br>    push to the aur</pre><p>And now, after a force push, everything work fine !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ycg6OLM1E5cQ-4MyDONSTg.png" /><figcaption>My package is on the AUR !</figcaption></figure><p>And after a <strong>yay -S dracut-numlock</strong> I have the right folder installed at the right place :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*JiUc_dl8bRatBHGfcXV8xQ.png" /><figcaption>The package is installed successfully</figcaption></figure><h4>🤔 Final thoughts about the errors I made &amp; the tools I used</h4><p>Obviously, at the beginning, I didn’t immediately understand the concept of the PKGBUILD file and how it is used in addition with pacman.</p><p>I’d be lying if I said I have read all the sentences in the wiki, but I think the fact that there’s so much specific documentation on one subject and no tutorials didn’t help either.</p><p>It’s a personal opinion, which others won’t share, but if you want other people to participate in a community, you have to think about that too when documenting things. This is also a problem found in KDE plasma documentation, for example, which is at best not updated and at worst non-existent. At least we can’t blame arch Linux for that ^^ The documentation is top-tier, the example not so much.</p><p>So the lessons learned here are pretty simple :</p><ul><li>read the wiki by taking your time and being relaxed</li><li>note-taking certainly helps</li><li>give yourself time to experiment and understand what you’re doing, my mistake here was to believe that all of this would be folded in a day</li><li>it’s going to sound contrary to what I wrote above, but take the time to read other people’s code</li><li>it’s not necessarily ideal for everyone, but you have to make do with the tools and skills you have, so trust the process</li></ul><p>The trouble with git at the end was rather annoying because I don’t see the point of checking the commits preceding the last one, since the last one is enough to detect version changes and so on. At least that’s what I understand from the wiki.<br>Anyway, it was a good excuse to brush up on the classic git squash 😉</p><p>For the tools, beside the wiki, I use ChatGPT mainly to explain concept and code if needed. The idea is mostly to gain time. I use obsidian for taking note and the arch sub-reddit if I have a question. All my research are made on the arch wiki, the sub-reddit and stackoverflow.</p><p>That’s all folks, if you made your way so far, I hope you’ve learned a thing or two, and thanks for taking the time to read all this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9117d07494d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add a real tiling window manager in KDE — the one-minute setup]]></title>
            <link>https://a2nb.medium.com/add-a-real-tiling-window-manager-in-kde-the-one-minute-setup-a461ce6a22d8?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/a461ce6a22d8</guid>
            <category><![CDATA[tiling]]></category>
            <category><![CDATA[arch]]></category>
            <category><![CDATA[tiling-window-manager]]></category>
            <category><![CDATA[kde]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Wed, 11 Oct 2023 16:55:55 GMT</pubDate>
            <atom:updated>2023-10-11T21:31:00.743Z</atom:updated>
            <content:encoded><![CDATA[<h3>Add a real tiling window manager in KDE — the one-minute setup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JHLZ9aW4Ww1eumAa6x1FQg.png" /><figcaption>Bismuth in action on KDE</figcaption></figure><p><em>The purpose of this story is to add a real TWM to our Linux with Bismuth.</em></p><p><a href="https://youtu.be/QNnQaYi1c5A">A YouTube video is also available here !</a></p><p>So you want to add a tiling window manager to KDE. You’re in the right place !</p><p>And for that we are going to use <a href="https://github.com/Bismuth-Forge/bismuth">the Bismuth package, available on GitHub</a>.</p><p>But you’re going to tell me that this feature <a href="https://linuxiac.com/kde-plasma-5-27-desktop-environment/">is already available in plasma 5</a>. And you’re right ! With the version 5 of Plasma, we can use super+T to show and use a tiling utility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qi8OGZFcYfbIUMaCo8TB-w.png" /><figcaption>The native plasma TWM</figcaption></figure><p>But I don&#39;t like this solution at all because it doesn’t automatically tile my windows and I cannot dynamically switch between different layout. And these two features are mandatory for me.</p><p>In the old days I have used <a href="https://github.com/esjeon/krohnkite">Krohnkite</a>, but the package is not maintained anymore, so I used Bismuth that is a kind of fork of Krohnkite.</p><h4>🚀 Installation</h4><p>Because I use EndeavorOS, I just have to use the AUR package (<a href="https://aur.archlinux.org/packages/kwin-bismuth">https://aur.archlinux.org/packages/kwin-bismuth</a>) :</p><pre>yay -S kwin-bismuth</pre><p>In the repository, you have another options if you use other Linux distribution.</p><h4>⌨️ Settings &amp; shortcut</h4><p>After the installation process, we just have to go to the system settings, and then the window management tab and the window tiling sub-tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0QnIMBgG0GzOUzMs40J-Vg.png" /></figure><p>In this page, you can modify all the options you want :</p><ul><li>separate layouts for each activity or virtual desktop</li><li>add restriction</li><li>choose the layouts you want in the customize layouts button</li></ul><p>In the window rules button, you can add option for specific program to be ignored or float.<br>In the appearance tab, you have the opportunity to add gutter between each window.</p><p>If you want to have a border color around the active window, you have to go to the Appearance tab and window decorations sub-tab and select the bismuth decorations.<br>This has the effect to remove the title bar of all the windows and add a colored border around the active window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gDX7at_VZ-h68dA2qhVzjQ.png" /></figure><p>The final step is to check if the shortcut is ok for you and for that you just have to go to the shortcut tab and window tiling sub tab.</p><p>The only downside I found of this solution, is that the package is not under active development because the original developer have not the time for that. So if you want to help, go to the GitHub repository and check for the current issues.</p><p>This has the effect to include in the script some weird user experience like :</p><ul><li>when the script is load for the first time, after a boot for example, no gutter is applied, so I have to hit my shortcut for switching between layout to actually have them applied</li><li>we don’t have the possibility to set up the default layout, so it always starts with the first layout you have checked on the settings list</li></ul><h4><strong>🍷 Another tips</strong></h4><p>Another tip I want to share with you is some tricks to handle some weird behavior with windows that have a mandatory minimum width, for example the system settings window.</p><p>The problem is pretty straight forward, if your actual layout doesn’t have enough space left for handling the width of the window, the window overlaps the other window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A45SdxY1eM79anlvqgw_bA.png" /></figure><p>With the following rules (system settings, window management, window rules) you can avoid that :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*LcQh7T4_j2lTiS2Wy4m9DQ.png" /></figure><p>Another behavior that is odd sometime is Dolphin that have a wrong size too, even if there are no another windows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*504H2LlnzrLWC5kGcFom0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*uizOrU-Wl5POupGuDwREng.png" /></figure><p>For avoiding that, we can apply the following rule :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*pWsbTinxCmHqrHP2rFHtEA.png" /></figure><p>And that’s it folks :)<br>See you later for another one !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a461ce6a22d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debuging kwin forceblur — SITREP 2]]></title>
            <link>https://a2nb.medium.com/debuging-kwin-forceblur-sitrep-2-5fe0c53da9ff?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fe0c53da9ff</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[kde]]></category>
            <category><![CDATA[kde-plasma]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Tue, 26 Sep 2023 13:43:32 GMT</pubDate>
            <atom:updated>2023-09-26T13:46:29.406Z</atom:updated>
            <content:encoded><![CDATA[<h3>Debuging kwin forceblur — SITREP 2</h3><p>The SITREP series is a “blog like” article that I wrote to note and share some of my research, debugging or work. Take it like a vlog if you want.</p><p>I hope you find something interesting in it. Or, in the worst case scenario, I hope you have learned something reading it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FYFkpsHWCsNUUo%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FYFkpsHWCsNUUo&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExMWFqeXhjMjZyMXplMWN4aG9tZWhtaGhueXZvYnBoZnJzZTkyZzEzYyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FYFkpsHWCsNUUo%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="394" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f1679f5df2a736275931666ce48a963/href">https://medium.com/media/0f1679f5df2a736275931666ce48a963/href</a></iframe><p>This is the following part of my <a href="https://medium.com/@a2nb/debuging-kwin-forceblur-sitrep-1-587946f3a18e">previous attempt</a> to debug KWIN Force Blur.</p><p>Okai for some reason I’ve never found a clue why the script doesn’t crash and at the same time doesn’t work.</p><p>So I decided to go for another journey on debugging this script and the first step was pretty simple : transforming the QML script into a JS script.</p><p>Why I&#39;m doing that ? Because <a href="https://develop.kde.org/docs/plasma/kwin/">in the documentation</a> the example say to do a JS script, so I supposed that the JS is the new format the dev want for the kwin script. But, hey, keep in mid that the documentation of KDE Plasma is pretty inconsistent in the best case and just non-existent in the worst case.</p><p>The second point is that the JS script is reloaded correctly when I disable and then enable the script whereas the QML script needs a reboot for some reason 🥸</p><p>So I managed to do something like that :</p><pre>function getSettings() {<br>  const brutTargets = &#39;kitty\nkeepassxc\nurxvt&#39;;<br>  const targets = brutTargets.split(&#39;\n&#39;).map((target) =&gt; target.trim().toLowerCase());<br>  return targets;<br>}<br><br>function blurWindow(client) {<br>  var id = client.windowId;                                   // client window id<br>  var type = client.windowType.toString();                    // client window type<br>  var role = client.windowRole.toString().toLowerCase();      // client window role<br>  var cls = client.resourceClass.toString().toLowerCase();    // client window class<br>  var name = client.resourceName.toString().toLowerCase();    // client window name<br><br>  const targets = getSettings();<br><br>  if (targets.length &gt; 0 &amp;&amp; (targets.includes(name) || targets.includes(cls) || targets.includes(type) || targets.includes(role))) {<br>    // blur the client<br>  }<br>}<br><br>function init() {<br>  print(&#39;PFB -- launch init&#39;);<br><br>  // EXISTING CLIENTS<br>  const clients = workspace.clientList();<br><br>  print(&#39;PFB --&#39;, clients.length, &#39;found&#39;);<br><br>  for (var i = 0; i &lt; clients.length; i++) {<br>    print(&#39;PFB -- old client&#39;, clients[i].windowId);<br>    blurWindow(clients[i]);<br>  }<br><br>  // NEW CLIENTS<br>  workspace.clientAdded.connect(function(client) {<br>    print(&#39;PFB -- new client&#39;, client.windowId);<br>    blurWindow(client);<br>  });<br><br>}<br><br>init();</pre><p>ATM I don&#39;t have set up the config window because the first thing I want to try is to blur a window. If the blur work, I’m going to do it next.</p><p>OK, now I reach the complex part : how to add the blur effect ?</p><p>I have some idea :</p><ul><li>run the same command line</li><li>use the kwin api if they propose the method for that</li><li>praise raptor jesus to give me the answer</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FuMD4EkFsDdFHG%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FuMD4EkFsDdFHG%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FuMD4EkFsDdFHG%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="348" frameborder="0" scrolling="no"><a href="https://medium.com/media/81552cb2206b2533412ff72829425b82/href">https://medium.com/media/81552cb2206b2533412ff72829425b82/href</a></iframe><p>After trying to figure out how to execute a command line and post some question on diverse forum (<a href="https://www.reddit.com/r/kde/comments/16rt8yr/exec_script_in_kwinscript_js/">reddit</a>, <a href="https://discuss.kde.org/t/migrating-an-old-kwin-script/5367">kde discuss</a>), where I never receive an answer, I decide to turn my focus on the KWIN API.</p><p>In <a href="https://develop.kde.org/docs/plasma/kwin/api/">this page</a> I found all the methods, functions and properties for the API and nothing seem to give me the ability to add the blur or call for a command.</p><p>I also have listed all the “key” accessible via the “client” object like so :</p><pre>Object.getOwnPropertyNames(client)</pre><p>But I found nothing that can help me in the list…</p><p>This is just after losing myself into my web research that <a href="https://www.reddit.com/r/kde/comments/g4rkzy/need_help_how_does_calldbus_works_in_kwin_script/">I found this post</a>.</p><p>Hum dbus, yeah, why not after all.</p><p>Okai I never used this stuff, so I read pretty quickly the documentation posted <a href="https://develop.kde.org/docs/features/d-bus/">here</a>. And I check to the qdbus bash command help :</p><pre>qdbus --help                 <br>Usage: qdbus [--system] [--bus busaddress] [--literal] [servicename] [path] [method] [args]<br><br>  servicename       the service to connect to (e.g., org.freedesktop.DBus)<br>  path              the path to the object (e.g., /)<br>  method            the method to call, with or without the interface<br>  args              arguments to pass to the call<br>With 0 arguments, qdbus will list the services available on the bus<br>With just the servicename, qdbus will list the object paths available on the service<br>With service name and object path, qdbus will list the methods, signals and properties available on the object<br><br>Options:<br>  --system          connect to the system bus<br>  --bus busaddress  connect to a custom bus<br>  --literal         print replies literally</pre><p>Actually, this is the help command that help me the most in particular for this sentence :</p><blockquote>With 0 arguments, qdbus will list the services available on the bus<br>With just the servicename, qdbus will list the object paths available on the service<br>With service name and object path, qdbus will list the methods, signals and properties available on the object</blockquote><p>Ok that pretty cool, I don&#39;t have to search for days where is the list of the service !</p><p>After many tries and test to figure out what service I have to use, I found that :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SGJ7sU3eRZxggR7H2ODang.png" /></figure><pre>org.kde.KDBusService.CommandLine                -- int(QStringList arguments, QString working-dir, QVariantMap platform-data)</pre><p>And that the point where I am actually because when I run the command I have the following error and I don&#39;t find why wet :</p><pre>qdbus org.kde.krunner /org/kde/krunner org.kde.KDBusService.CommandLine &quot;ls&quot; &quot;~&quot; &quot;{}&quot;<br>Sorry, can&#39;t pass arg of type &#39;QVariantMap&#39;.</pre><p>I’ll leave you there and go for a coffee. I’ll let you know as soon as I have a solution 😎</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fe0c53da9ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add custom touch-gesture in KDE — the one-minute setup]]></title>
            <link>https://a2nb.medium.com/add-custom-touch-gesture-in-kde-the-one-minute-setup-13d9a922b00f?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/13d9a922b00f</guid>
            <category><![CDATA[kde]]></category>
            <category><![CDATA[arch]]></category>
            <category><![CDATA[gestures]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[endeavouros]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 15:15:13 GMT</pubDate>
            <atom:updated>2023-09-21T17:49:42.656Z</atom:updated>
            <content:encoded><![CDATA[<h3>Add custom touch-gesture in KDE — the one-minute setup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*o7xZ4NPSSuq5T9tHJFUBJA.png" /><figcaption>Touché the GUI of touchegg</figcaption></figure><p><em>The purpose of this story is to add some touch gesture to our Linux with touché and touchégg.</em></p><p><a href="https://www.youtube.com/watch?v=y5BISs4qYi4">A YouTube video is also available here !</a></p><p>Today we are going to add touch-gesture to our KDE. Obviously, this works only if you have a touchpad.</p><p>I am going to show you how to install the right package, how the settings GUI works, and two custom example.</p><p>So, we need two packages :</p><ul><li>touchégg — <a href="https://github.com/JoseExposito/touchegg">https://github.com/JoseExposito/touchegg</a></li><li>touché — <a href="https://github.com/JoseExposito/touche">https://github.com/JoseExposito/touche</a></li></ul><p>Both are created by JoseExposito on his GitHub. For the both packages the readme is very well written so if you want extra settings or have questions read it first.</p><p>I use Endeavour OS, so I’m going to do the step for the arch Linux based distro.</p><h4>🚀 Installing the package</h4><p>For installing touchegg nothing special, I use “pacman” :</p><pre>sudo pacman -S touchegg</pre><p>After that, we need to enable the package with “sytemctl”, like so, the service is automatically launched on the next reboot :</p><pre>sudo systemctl enable touchegg.service --now</pre><p>After that, we need to reboot. This is a mandatory step.</p><p>The package is configurable with a configuration file, but I found the GUI well done and very simple to use, so let’s install it :</p><pre>yay -S touche</pre><p>I used “yay” but you can do it with “paru” too.</p><p>After the installation, you just have to launch the “Touché” program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*vOnblnGbhsdeXeCMDxE0Ag.png" /><figcaption>The Touché GUI</figcaption></figure><p>In the left column, we have a list of applications and in the right the settings for the selected application.</p><p>Next I want to showcase you some gesture I set up in my pc. The purpose is to show you the ability of the program to do powerful and customizable gestures.</p><h4>🌎 Browser navigation gesture</h4><p>The first gesture I want to show you is for going forward or backward in Vivaldi history with a 3 fingers swipe left or right, like with your phone.</p><p>I found this gesture very practical, especially when I search the web for some forum answers or read a bunch of documentation : I can swipe to the previous page very quickly (in this case the search result page) and check another link, and go back to the result and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFNgXkylX3g4BiYxz3wKAA.gif" /><figcaption>Example of search with the use of the gesture in Vivaldi</figcaption></figure><p>For that, you just need to check the keyboard shortcut for the action in Vivaldi, we search for the “history back” and the “history forward” shortcut (in Vivaldi you can do ctrl + F1 if you want to view all the shortcut or directly via the configuration menu).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*mSdOHxHcJHNFW_fk9a-78w.png" /></figure><p>When you have found the right shortcut, we need to add it to the touchegg configuration.</p><p>So we add Vivaldi to the list of the applications and, in the right column, under the “swipe with 3 fingers” we add the following :</p><ul><li>left, keyboard shortcut, and the shortcut is Alt + Left</li><li>right, keyboard shortcut, and the shortcut is Alt + Right</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*x13S7HAtbLnceyCT1yUGRQ.png" /><figcaption>The configuration for Vivaldi</figcaption></figure><p>And voilà, it&#39;s that easy.</p><p>The next example I want to show you is with KDE integration. I want to do two things :</p><ul><li>when I do “swipe up with 3 fingers” I want the desktop overview to be shown</li><li>when I do “swipe down with 3 fingers” I want the krunner launcher to be shown</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VWWvIicrdv4mFYZ-8hYbsQ.png" /><figcaption>The desktop overview</figcaption></figure><p>For these two gestures we have again the use of the “keyboard shortcut” :</p><ul><li>for the desktop overview, the shortcut is found on the setting under the desktop effect tab : meta + w</li><li>and for krunner we just have to check the shortcut in the shortcut tabs, I have created a custom shortcut for krunner : meta + p</li></ul><p>Next, in the “global gesture” application we just have to add, like for Vivaldi, the gesture :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*3KIBV7yj2KjrXUjL3tvAFg.png" /><figcaption>The settings for the custom KDE gesture.</figcaption></figure><p>And that’s it !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e2TI4DYMDVoKyfrEn1Xc5Q.gif" /><figcaption>The result for the two gestures we made.</figcaption></figure><p>Now it’s up to you to find or create useful gestures :)</p><p>Some examples that just pop in my mind :</p><ul><li>play, pause, forward, backward video on YouTube or in a video editor application</li><li>lock the desktop or go to sleep</li><li>execute some custom command (via the “execute a command” option)</li><li>open a program or a setting</li></ul><p>etc …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13d9a922b00f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debuging kwin forceblur — SITREP 1]]></title>
            <link>https://a2nb.medium.com/debuging-kwin-forceblur-sitrep-1-587946f3a18e?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/587946f3a18e</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[kde-plasma]]></category>
            <category><![CDATA[kde]]></category>
            <category><![CDATA[kwin]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Thu, 24 Aug 2023 18:45:18 GMT</pubDate>
            <atom:updated>2023-08-24T18:45:18.834Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Debugging kwin forceblur — SITREP 1</strong></h3><p>The SITREP series is a &quot;blog like&quot; article that I wrote to note and share some of my research, debugging or work. Take it like a vlog if you want.</p><p>I hope you find something interesting in it. Or, in the worst case scenario, I hope you have learned something reading it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F2xF8gHUf085aNyyAQR%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F2xF8gHUf085aNyyAQR%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F2xF8gHUf085aNyyAQR%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="301" frameborder="0" scrolling="no"><a href="https://medium.com/media/3060d6835e96121708a1a46e34bedb0b/href">https://medium.com/media/3060d6835e96121708a1a46e34bedb0b/href</a></iframe><p>Today, I have reinstalled <a href="https://endeavouros.com/">EOS</a> on my new <a href="https://www.tuxedocomputers.com/">Tuxedo</a> pc. After a reboot and some config I have setup <a href="https://sw.kovidgoyal.net/kitty/">kitty</a> and the theme I wanted for it. In my config, I have setup the background to have 80% of transparency, and, with the aid of <a href="https://github.com/esjeon/kwin-forceblur">forceblur</a> I blurred the background.</p><p>In theory.<br>With this new install this script doesn’t work.</p><p>Ok so, why ? Have I made a mistake ? After some test and a certain amount of reboot, I decided to check the github page of the project. And I found an issue referencing that the script doesn’t work since KDE update to 5.25.</p><p>Ok, but that was a long time ago, but the last commit (<a href="https://github.com/bouteillerAlan/kwin-forceblur/commit/1f92ed59d4e445587ad4245f374f90f61850f29f">1f92ed5</a>) on this project is old too : Feb 13th 2022.</p><p>So with that in mind, I decided to embark on another journey for debugging some KDE plugins.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl2Jeio2n97D5life0%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl2Jeio2n97D5life0%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fl2Jeio2n97D5life0%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f6c2b57603c98e937d0336e99a3f706/href">https://medium.com/media/5f6c2b57603c98e937d0336e99a3f706/href</a></iframe><p>First step : I checked the tutorial of the kwin script provided by KDE, for two main raisons :<br>- I have never really done a kwin script, so maybe some stuff may change compared to the development of a plasmoid for example<br>- I know that kde have made some update so I wanted to check the command needed for installing the plugin</p><p>There I found what I have searched for :<br>Install a kwin script :<br><strong>kpackagetool5 — type=KWin/Script -i ~/Downloads/forceblur</strong></p><p>If you want to enable it :<br><em>The key is the name of the script followed by &quot;Enabled&quot;</em><br><strong>kwriteconfig5 — file kwinrc — group Plugins — key forceblurEnabled true</strong></p><p>Next we can reload kwin :<br><strong>qdbus org.kde.KWin /KWin reconfigure</strong></p><p>The log is found on the <strong>journalctl</strong> :<br>- the last log in live : <strong>journalctl -f</strong><br>- filtered : <strong>journalctl -f QT_CATEGORY=js QT_CATEGORY=kwin_scripting</strong></p><p>So, after a clone of the repo, I started by updating the architecture of the project like the documentation recommended doing so.</p><p>Nothing funky here, I just move the <strong>main.qml</strong> file to a new folder called &quot;code&quot;.<br>The new file organisation is pretty simple : <br>├── contents<br>│ ├── code<br>│ │ └── main.qml<br>│ ├── config<br>│ │ └── main.xml<br>│ └── ui<br>│ └── config.ui<br>└── metadata.json</p><p>The next step is to move the old <em>metadata.desktop</em> to his new format, <em>metadata.json</em>.<br>Here, again, nothing new, I just have to move the right key and value into the json :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*4neCFU-tw-ziR6mxd2a-UA.png" /><figcaption>the new metadata.json</figcaption></figure><p>And voilà, <a href="https://github.com/esjeon/kwin-forceblur/pull/34">after opening the pr on esjeon repo</a>, I started to check what the bug can be.</p><h4>So, first, what is the behaviour of the problem ?</h4><p>- Since I know that the script work well with kitty in the past I have added kitty on the target list.<br>- When kitty is already open and I turn off and on the script, the console is blurred. So, already created windows works fine when the script is reactivated via the kwin settings.<br>- When the script is active, and I pop a new kitty window, the window is not blurred.</p><p>Ok, if I check the output of the <strong>journalctl</strong> nothing weird appear, I just have the two logs created by esjeon on is code :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*jxobEEXA6Ueallh7POvnOg.png" /></figure><p>The kitty keyword is present, and the script is loaded.</p><p>So I decided to remove the two following possibilities for the bug : <br>- the script doesn’t load<br>- the parameter window doesn’t work</p><p>We need to check the code.</p><h4>How works the code made by esjeon ?</h4><p>(<a href="https://github.com/esjeon/kwin-forceblur/blob/master/contents/ui/main.qml">https://github.com/esjeon/kwin-forceblur/blob/master/contents/ui/main.qml</a>)</p><ul><li>first we have an Item identified has root, nothing new here</li><li>three read-only properties are defined to store the value of the params</li><li>a <strong>DataSource</strong> identified has <strong>shell</strong> is created for executing some command</li><li>a function <strong>onClientAdded</strong> handle the call to the datasource <strong>shell </strong>with the check of the class name of the window : if the targeted window have the same name as a value set in the parameters, let’s blur it</li><li>in this function, the id of the window is retrieved by the following code : <strong>var wid = “0x” + client.windowId.toString(16);</strong></li><li>the command call for blurring the window is a <strong>xprop</strong> command</li><li>a function called <strong>onClientGeometryChanged</strong> allows updating the blur region if the user change the height or the width of a window</li><li>nothing particular in the function, the cmd called for the update is the same as the one in the <strong>onClientAdded</strong> function</li><li>a function called <strong>registerHintUpdater</strong> is present too, it’s called in place of the cmd if the user chose to blur the content of the window via the parameter</li><li>and finally the bootloader of this script (if I may) : the <strong>onCompleted</strong> component, this thing allows you to execute what you want when the script is activated. Inside we have, for example, the two logs that I have talk before. We retrieve, too, the call for blurring the already present windows and the signal that called the <strong>onClientAdded</strong> function when a user adds a window <strong>workspace.onClientAdded.connect</strong>.</li></ul><h4>What part of that may fail ?</h4><p>Maybe the command ? Maybe the <strong>onClientAdded</strong> signal ? Maybe the id of the window is not understood ?</p><p>The fact that the already present kitty is blurred let me think that the command is ok, but I wanted to check that for sure.</p><p>For that, I just added a <strong>print </strong>with the generated command :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CU4qs3AbItgofjyZYKc-jQ.png" /></figure><p>If I execute this command with the id of a non-blurred kitty window, the window is blurred.</p><p>For being sure everything is fine, I change the id (<strong>“0x” + client.windowId.toString(16)</strong>) by the one given by the client object (<strong>client.windowId</strong>), but the result is exactly the same.</p><p>I have taken the time to add two signals to the <strong>shell </strong>DataSource :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*xAe-yNrWID4boowi8VpdDg.png" /></figure><p>The second signal gives me the opportunity to check the stdout and the stderr of the command. But when I do that, nothing weird too…</p><p>So […] next I have created a &quot;debug&quot; function called by the &quot;onClientAdded&quot; signal, the purpose of the function is just to check if the signal is really triggered and the &quot;client&quot; really transferred by it.</p><p>By the way, the signal is still present <a href="https://develop.kde.org/docs/plasma/kwin/api/#signals">on the documentation,</a> so no update to do here.</p><p>And with no surprise, everything looks fine :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*_TQoJ3qMwNoWbhhYGhP6HQ.png" /></figure><p>Ok I need a break […] and a coffee, I stop this SITREP here and give you any update of this situation on another one.</p><p>The code made so far is here : <a href="https://github.com/bouteillerAlan/kwin-forceblur/commit/08bc86e4974d83498b43d47d265b3acf0c7f735e">https://github.com/bouteillerAlan/kwin-forceblur/commit/08bc86e4974d83498b43d47d265b3acf0c7f735e</a></p><p>See ya folk.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=587946f3a18e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding value when you reach the start of a flatlist — the one-minute setup]]></title>
            <link>https://a2nb.medium.com/adding-value-when-you-reach-the-start-of-a-flatlist-the-one-minute-setup-a2e649c1d837?source=rss-e93261f2c14------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2e649c1d837</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[flatlist]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Bouteiller < A2N > Alan]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 18:25:30 GMT</pubDate>
            <atom:updated>2023-07-18T18:25:30.576Z</atom:updated>
            <content:encoded><![CDATA[<h3>Adding value when you reach the start of a flatlist — the one-minute setup</h3><p><em>This story is related to another story, talking about making a horizontal calendar with flatlist, you can find this story </em><a href="https://a2nb.medium.com/how-to-make-a-horizontal-calendar-slider-in-react-native-with-flatlist-f1797ffa4dee"><em>just here</em></a><em>.<br>If you don’t want to add data at the start but at the end, </em><a href="https://a2nb.medium.com/adding-value-when-you-reach-the-end-of-a-flatlist-the-one-minute-setup-d02df61c4aa7"><em>check the answer here</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*2b04pP96BtuLBg0ZFtWxDA.png" /></figure><p>Ok, so you want to add data at the beginning of your flatlist ?</p><p>We have a problem right now: flatlist provides a parameter to detect when the user has reached the end, but not to detect when the user has reached the beginning!</p><p>For this particular problem we have, hopefully, a workaround !</p><p>But first we need to build a simple flatlist.</p><h3>Disclaimer</h3><p>For this tutorial purpose :</p><ul><li>I assume you know what a flatlist is</li><li>I used native-base for the style, but the whole thing works the same with React Native (<a href="https://nativebase.io/">https://nativebase.io/</a>)</li></ul><h3>Setting up a very basic flatlist</h3><p>So, for starting, let’s create a simple flatlist showing number from 0 to 5.</p><p>The code look like this :</p><pre>import React, { type ReactElement, useState } from &#39;react&#39;;<br>import { Center, FlatList } from &#39;native-base&#39;;<br>import { type ListRenderItemInfo, type ScaledSize, Dimensions } from &#39;react-native&#39;;<br><br>const FlatListDemo = (): ReactElement =&gt; {<br>  const windowDimensions: ScaledSize = Dimensions.get(&#39;window&#39;);<br>  const [data] = useState&lt;number[]&gt;([0, 1, 2, 3, 4, 5]);<br><br>  /**<br>   * render the item for each flatlist element<br>   * @param {number} item just the number<br>   * @param {number} index index of the element<br>   * @returns {ReactElement} native base center element with the number in it<br>   */<br>  function renderItem(item: number, index: number): ReactElement {<br>    return &lt;Center<br>      backgroundColor={`blue.${index+1}00`}<br>      width={windowDimensions.width}<br>    &gt;<br>      {item.toString()}<br>    &lt;/Center&gt;;<br>  }<br><br>  return (<br>    &lt;FlatList<br>      data={data}<br>      horizontal={true}<br>      snapToInterval={windowDimensions.width}<br>      keyExtractor={(item: number, index: number): string =&gt; index.toString()}<br>      renderItem={(itemInfo: ListRenderItemInfo&lt;number&gt;) =&gt; {<br>        return renderItem(itemInfo.item, itemInfo.index);<br>      }}<br>    /&gt;<br>  );<br>};<br><br>export default FlatListDemo;</pre><p>Nothing much special, we define a flatlist with some data and set it up to a certain width for having the list with a scrollbar.</p><p>The <strong>snapToInterval</strong> is given the same value as the element width. This tells the flatlist that we want the user to scroll one element at a time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*mlitkkihD1qkL_zZ_cVj2g.gif" /><figcaption>We can swipe !</figcaption></figure><h3>Adding data when the user reaches the start</h3><p>Ok, I promise you a workaround, so here we go : the <strong>onScroll</strong> parameter</p><pre>// use `onScroll` to handle the data when the user reach the start<br>onScroll={(event: NativeSyntheticEvent&lt;NativeScrollEvent&gt;): void =&gt; { handleScroll(event); }}</pre><p>The <strong>onScroll </strong>event gives us the ability to read the real value of the scroll offset, with this value we just have a little math to do and, voilà, we have our “detector” 🙃 :</p><pre>/**<br> * add data to the start of the flatlist<br> * @param {NativeSyntheticEvent&lt;NativeScrollEvent&gt;} event scroll event<br> */<br>function prependData(event: NativeSyntheticEvent&lt;NativeScrollEvent&gt;): void {<br>  // if distanceFromStart.x === 0 we reach the start of the list<br>  const distanceFromStart: NativeScrollPoint = event.nativeEvent.contentOffset;<br>  if (distanceFromStart.x === 0) {<br>    console.log(&#39;prepend !&#39;);<br>  }<br>}</pre><p>For now, the code look like that :</p><pre>import React, { type ReactElement, useState } from &#39;react&#39;;<br>import { Center, FlatList } from &#39;native-base&#39;;<br>import {<br>  type ListRenderItemInfo,<br>  type ScaledSize,<br>  Dimensions,<br>  type NativeSyntheticEvent,<br>  type NativeScrollEvent, type NativeScrollPoint<br>} from &#39;react-native&#39;;<br><br>const FlatListDemo = (): ReactElement =&gt; {<br>  const windowDimensions: ScaledSize = Dimensions.get(&#39;window&#39;);<br>  const [data, setData] = useState&lt;number[]&gt;([0, 1, 2, 3, 4, 5]);<br><br>  /**<br>   * render the item for each flatlist element<br>   * @param {number} item just the number<br>   * @param {number} index index of the element<br>   * @returns {ReactElement} native base center element with the number in it<br>   */<br>  function renderItem(item: number, index: number): ReactElement {<br>    return &lt;Center<br>      backgroundColor={`blue.${index+1}00`}<br>      width={windowDimensions.width}<br>    &gt;<br>      {item.toString()}<br>    &lt;/Center&gt;;<br>  }<br><br>  /**<br>   * add data to the start of the flatlist<br>   * @param {NativeSyntheticEvent&lt;NativeScrollEvent&gt;} event scroll event<br>   */<br>  function prependData(event: NativeSyntheticEvent&lt;NativeScrollEvent&gt;): void {<br>    // if distanceFromStart.x === 0 we reach the start of the list<br>    const distanceFromStart: NativeScrollPoint = event.nativeEvent.contentOffset;<br>    if (distanceFromStart.x === 0) {<br>      console.log(&#39;prepend !&#39;);<br>    }<br>  }<br><br>  return (<br>    &lt;FlatList<br>      data={data}<br>      horizontal={true}<br>      snapToInterval={windowDimensions.width}<br>      keyExtractor={(item: number, index: number): string =&gt; index.toString()}<br>      renderItem={(itemInfo: ListRenderItemInfo&lt;number&gt;) =&gt; {<br>        return renderItem(itemInfo.item, itemInfo.index);<br>      }}<br>      onScroll={(event: NativeSyntheticEvent&lt;NativeScrollEvent&gt;): void =&gt; { prependData(event); }}<br>    /&gt;<br>  );<br>};<br><br>export default FlatListDemo;</pre><p>The result :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*43f2o6Rh_OAEJdazGbTJ-A.gif" /><figcaption>That work ! :)</figcaption></figure><p>Ok, now we can add data to your list. Like so :</p><pre>if (distanceFromStart.x === 0) {<br>  const d = [[20, 21, 22, 23, 24, 25], data];<br>  setData(d.flat());<br>}</pre><p>I have prefixed the added data with 2 because here, unfortunately, we have a new problem !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*ARdpe5ikYAHHPpyN5_eyIw.gif" /></figure><p>As you can see in the gif, the index where the user is located is not preserved!<br>The result is an odd interaction for the user. We need to correct this.</p><h3>Solving the index problem</h3><p>Our problem is pretty straight forward : when the data is added the size of the list changed, that mean for the same index we have another data. The flatlist doesn’t move the user to the same index, but the data changed for the user.</p><p>We need to store where the user is “looking”. For that, we need to use the following parameter :</p><pre>// 50 means that item is considered visible if it&#39;s visible for more than 50 percents<br>viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}<br>onViewableItemsChanged={onViewableItemsChanged.current}</pre><p>Here <strong>onViewableItemsChanged </strong>is a reference<strong> :</strong></p><pre>const onViewableItemsChanged = useRef((info: onViewableItemsChangedInfo): void =&gt; { setCurrentObjectInfo(info); });<br>const [currentObjectInfo, setCurrentObjectInfo] = useState&lt;onViewableItemsChangedInfo | undefined&gt;(undefined);</pre><p>We also need to define the <strong>getItemLayout </strong>parameter, this is mandatory if you want the <strong>onViewableItemsChanged </strong>working correctly :</p><pre>getItemLayout={(data: number[] | null | undefined, index: number): { length: number, offset: number, index: number } =&gt; ({<br>  length: windowDimensions.width, offset: windowDimensions.width * index, index<br>})}</pre><p>Ok […] let&#39;s summarize a little bit here :</p><ul><li>we have created a reference for the event when the item showed by the flatlist change called <strong>onViewableItemsChanged</strong></li><li>we have mapped a state to the <strong>onViewableItemsChanged </strong>reference like so when the item changed the state is updated</li><li>we have defined the trigger point for considering an item visible to 50% of its own width</li><li>we have implemented the <strong>getItemLayout </strong>parameter</li></ul><p>By the way, the <strong>onViewableItemsChangedInfo </strong>type is just :</p><pre>export interface onViewableItemsChangedInfo {<br>  viewableItems: ViewToken[]<br>  changed: ViewToken[]<br>}</pre><p>If we create a little useEffect we can check that our setup work fine :</p><pre>useEffect(() =&gt; { console.log(&#39;the data length is&#39;, data.length); }, [data]);<br>useEffect(() =&gt; { console.log(&#39;the index of the visible item is&#39;, currentObjectInfo?.viewableItems[0].index); }, [currentObjectInfo?.viewableItems[0].index]);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*N1xaJ-10IKqEHwGGo3SjyA.gif" /><figcaption>Ok-We have the index!</figcaption></figure><p>Now that we have the index, we need to add the length of the new data to that index to get the new index.</p><pre>if (distanceFromStart.x === 0) {<br>  const newData = [20, 21, 22, 23, 24, 25];<br><br>  let indexToMove: number = 0;<br>  if (typeof currentObjectInfo?.viewableItems[0]?.index === &#39;number&#39;) {<br>    indexToMove = currentObjectInfo?.viewableItems[0].index;<br>    indexToMove = indexToMove + newData.length;<br>  }<br><br>  setData([...newData, ...data]);<br>}</pre><p>Because we have a known array in <strong>newData </strong>it’s easier to test that our solution work.</p><p>We have an array of 6, and we add 6 new elements, when the data is added we are at the index 0 of the first array so when the new data append we need to go to the new data length + the old index.</p><p>In our case it’s always the same (6), but if you do an API call, for example, you don’t know the length of your data in advance.</p><p>Now that we have the new index, we just have to move the user to this index.</p><p>We need to use the <strong>scrollToIndex </strong>function of the flatlist. For that, we have to use a reference to the flatlist :</p><pre>const demoFlatList = useRef();</pre><pre>&lt;FlatList<br>  ref={demoFlatList}<br>  ...</pre><p>Now we just have to give the right index to the function :</p><pre>/**<br> * set the given index for the flatlist<br> * @param {number} index the index you want the flatlist to be<br> * @param {boolean} isAnimated if you want an animated transition<br> */<br>function goToIndex(index: number, isAnimated: boolean): void {<br>  if (demoFlatList.current !== undefined) {<br>    demoFlatList.current.scrollToIndex({ index, animated: isAnimated });<br>  }<br>}</pre><p><em>The animation value is set to false because we want the scrolling to be invisible to the user.</em></p><pre>if (distanceFromStart.x === 0) {<br>  const newData = [20, 21, 22, 23, 24, 25];<br><br>  let indexToMove: number = 0;<br>  if (typeof currentObjectInfo?.viewableItems[0]?.index === &#39;number&#39;) {<br>    indexToMove = currentObjectInfo?.viewableItems[0].index;<br>    indexToMove = indexToMove + newData.length;<br>  }<br><br>  setData([...newData, ...data]);<br>  goToIndex(indexToMove, false);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*LYNPnjm4XOTAKye8SegIrg.gif" /><figcaption>Here we go :)</figcaption></figure><h3>And well done folks ! You have data at the beginning of your flatlist !</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2e649c1d837" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>