KDE Emacs

:: kde, emacs, tutorial, customization

By: Maciej Barć

Proper window size

Sometimes while the Emacs GUI window is tiled to a side or maximized small gaps may appear around the window. This "bug" can be worked around by:

  • right-click on the title bar,
  • "More Actions",
  • "Configure Special Window Settings…",
  • "Add Property",
  • "Obey Geometry Restrictions",
  • Select "Force" form the combo box,
  • Select "No" from the radio buttons.

Opening files from Dolphin in one Emacs instance

Emacs daemon can help with that. But before you run emacs --daemon, I need You to know that there might be a better way:

1
2
(unless (or noninteractive (server-running-p))
  (server-start))

Adding the above to Your Emacs config will cause Emacs to start a daemon after it is opened (and no other Emacs servers are running), this also does not require --daemon flag.

After the daemon is started You can open files by right-clicking on them and selecting to open them in "Emacsclient".

Furthermore: You also utilize --iconic and add emacs --iconic to your Plasma startup. This is way better than using emacs --daemon because you can just click on your taskbar to open the minimized Emacs window. Also, Emacs will load all Your graphical libraries and configurations so Your theme will look properly and not as if Emacs was being used on the console.

Breeze theme

Sadly I have not found any theme that would look like Plasma. I use the spacemacs theme which looks a little bit similar, especially the background color comes close to Breeze's dark background color.

Note that the theme which You load with the function load-theme is a different thing that the GTK theme Emacs uses.

The GTK theme should be enabled if Your Emacs version is built with GTK support. On Gentoo this setting is controlled with the gtk USE flag. Also the flag toolkit-scroll-bars can be enabled for a look of scroll-bars consistent with the selected toolkit.

Xresources

There is a different approach to theming Your Emacs that loading a theme defined in ELisp - You can use a ~/.Xresource file.

If you do not load any theme in your configuration Emacs will by default read the .Xresources file, unless the --no-x-resources flag is used.

Here are a few Xresources config files that come close to the default Breeze theme:

Dbus integration

Emacs can be built with FreeDesktop's D-Bus support to communicate over the dbus protocol. This can come handy when using ERC as it has a setting to enable desktop notifications on mentions (erc-desktop-notifications.el).

The dbus interface can also be utilized to query desktop-oriented daemons, for example this library talks to the Bluetooth daemon.

KDE development

Those are some ELisp libraries that I found while browsing GitHub, they might be useful for somebody who delves into KDE app development.

Opening files in different applications

In addition to async-shell-command and start-process-shell-command I wrote this small library that may come handy.

Outside Emacs, inside Plasma

Sadly the KDE team did not add support to emulate Emacs-like keys in Plasma itself, but some applications like, for example Kate have configuration options to customize the key bindings. This is a repository explaining how to setup Kate's bindings.

Pkgcheck-Flycheck

:: emacs, pkgcheck, gentoo, ebuild, tutorial

By: Maciej Barć

News

Repository

With this commit first GNU Emacs integration was merged into the pkgcheck repository.

History

Thanks

Huge thanks to Sam James and Arthur Zamarin for support and interest in getting this feature done.

Installation

Unmasking

The Flycheck integration is unreleased as of now, this will (hopefully) change in the future, but for now You need live versions of snakeoil, pkgcore and pkgcheck.

File: /etc/portage/package.accept_keywords/pkgcore.conf

1
2
3
dev-python/snakeoil  **
sys-apps/pkgcore     **
dev-util/pkgcheck    **

Also You will need to unmask app-emacs/flycheck and its dependencies.

File: /etc/portage/package.accept_keywords/emacs.conf

1
2
3
app-emacs/epl
app-emacs/pkg-info
app-emacs/flycheck

Emerging

Install pkgcheck with the emacs USE flag enabled.

File: /etc/portage/package.use/pkgcore.conf

1
dev-util/pkgcheck    emacs

Afterwards run:

1
2
emerge -1av dev-python/snakeoil sys-apps/pkgcore dev-util/pkgcheck
emerge -av --noreplace dev-util/pkgcheck

Configuration

Following is what I would suggest to put into your Emacs config file:

1
2
3
4
5
6
7
8
(require 'ebuild-mode)
(require 'flycheck)
(require 'flycheck-pkgcheck)

(setq flycheck-pkgcheck-enable t)

(add-hook 'ebuild-mode-hook 'flycheck-mode)
(add-hook 'ebuild-mode-hook 'flycheck-pkgcheck-setup)

If You are using use-package:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(use-package flycheck
  :ensure nil)

(use-package ebuild-mode
  :ensure nil
  :hook ((ebuild-mode . flycheck-mode)))

(use-package flycheck-pkgcheck
  :ensure nil
  :custom ((flycheck-pkgcheck-enable t))
  :hook ((ebuild-mode . flycheck-pkgcheck-setup)))

The lines with :ensure nil are there to prevent use-package from trying to download the particular package from Elpa (because we use system packages for this configuration).

Mkdocs with Scribble

:: racket, programming language, scribble

By: Maciej Barć

Intro

Instead of changing CSS style for Your Racket projects documentation, You may be interested in compiling Markdown files generated form Scribble source into HTML documentation website.

Creating MkDocs project

  1. Create docs directory and mkdocs.yml config file in current directory, along with a dummy index.md file in docs folder.

    1
    mkdocs new .
    
  2. Edit the name of the project.

    Replace Racket-Project with your project name.

    1
    2
    ---
    site_name: Racket-Project
    

Building Scribble

Generate markdown files form scribble documentation.

Replace Racket-Project.scrbl with path to your scribble documentation main source file.

1
scribble --markdown --dest ./docs --dest-name index.md Racket-Project.scrbl

Building Markdown

Compile HTML documentation from the markdown source.

1
mkdocs build

HTML files should appear in the site directory.

Running the server

Some features, like search for example are only available when running the mkdocs server.

1
mkdocs serve

Caveats

Some scribble functions do not look good or work correctly for markdown-to-HTML compilation by MkDocs.

  • table-of-contents - looks like a source block

  • index-section - letter links do not work

Example configuration

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
site_name: Racket-Ebuild
site_author: xgqt@riseup.net
site_description: library to ease ebuild creation
site_url: https://gitlab.com/gentoo-racket/racket-ebuild

repo_name: gentoo-racket/racket-ebuild
repo_url: https://gitlab.com/gentoo-racket/racket-ebuild

plugins:
  - search

theme:
  name: material

extra:
  social:
    - icon: fontawesome/brands/gitlab
      link: https://gitlab.com/gentoo-racket/racket-ebuild

Lenovo 81nc advanced bios options

:: hardware, laptop, tutorial

By: Maciej Barć

Accessing advanced BIOS menu

Preparation

First using a needle or a toothpick click a button on the right side of the laptop (indicated by a bent arrow), this will start the machine up in BIOS selection menu where you choose the BIOS setup option.

Then, in the BIOS menu disable option to check laptop charge level while it is shut down. If not disabled it will interfere with key combination that has to be pressed while laptop is shut down. This can be turned back after the advanced BIOS menu is enabled.

After that "Exit saving changes" and shutdown.

Keys

I thought it was a joke at first but it really is true that a special combination of keys has to be pressed depending on the laptop model (while it is shut down).

For my laptop it is as follows:

1
2
3
F4 4 r f v
F5 5 t g b
F6 6 y h n

References

systemd-custom-unit

:: system, systemd, tutorial

By: Maciej Barć

Template

File: /etc/systemd/system/APP.service

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[Unit]
Description=Run APP application

[Service]
Type=simple
ExecStart=/usr/bin/LANG APP_DIR/APP APP_ARGS
Restart=on-failure
User=root
WorkingDirectory=APP_DIR

[Install]
WantedBy=multi-user.target

Also, the application might need to reference a PID file, let systemD know abut it via PIDFile.

1
PIDFile=/tmp/APP.pid

Example

File: /etc/systemd/system/julia_dash_app.service

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[Unit]
Description=Run Julia Dash application

[Service]
Type=simple
ExecStart=/usr/bin/julia /root/julia_dash_app/main.jl
Restart=on-failure
User=root
WorkingDirectory=/root/julia_dash_app

[Install]
WantedBy=multi-user.target

Portage CI

:: continuous integration, gentoo, portage, quality assurance, testing

By: Maciej Barć

Potential benefits

Running tests

  • test BEFORE (src_test) and AFTER (pkg_postinst) installation
  • test if and how services break if they are not reloaded
  • test buildsystem configuration
  • sandbox enforces strict and consistent build rules
  • benchmarking with different compilation flags and libraries versions/releases

Configuration matrix

We can test across Cartesian product of different configuration settings, like:

  • USE flags
  • MAKEOPTS
  • CFLAGS, CXXFLAGS, CPPFLAGS, LDFAGS, RUSTFLAGS, etc.
  • arches (cross-compilation or run in qemu)
  • static linking
  • supported releases & versions of libraries (eg. glibc & musl)

Also, we could create diffs of installed files across different merges.

Reproducibility

  • mini overlay with ::gentoo or any other (eg. company's own) as master
  • record VCS (eg. git) hash of the dependent overlays

Binaries

  • grab dependencies from binhosts
  • distribute built binaries (maybe upload to a company's own artifacts server)
  • make AppImages

Getting there

How do we run this?

Do we want to write a proper tool, which we probably do or do we just run Portage + shells scripts?

Do we want to run under root, user, in eprefix, maybe all in docker?

Configuration files

The .portci directory contains the configuration.

Bug 799626

Link: bugs.gentoo.org/799626

Instead of using Ansible, Python, Yaml or Scheme we might use something similar to this for simple configuration, or if gets merged to upstream Portage the better.

Worth mentioning is the idea from Michał Górny who proposes to configure portage with toml files, like the example given in the bug report.

1
2
3
4
5
6
7
8
[package.unmask]
~virtual/libcrypt-2

[package.use.mask]
sys-libs/libxcrypt -system -split-usr

[package.use.force]
sys-libs/glibc -crypt

Also, package.x + Toml == a match made in heaven, it looks very nice!

Portage

:: gentoo, portage

By: Maciej Barć

Switching from a git repository hosting

For nearly 2 years I have been synchronizing settings between my Gentoo machines via a git repository that is installed system-wide via portage itself.

This actually gets a little tiresome and slow as the package that installs the configuration has to be re-installed each time we want to update the settings.

So I thought it could be cool if I can just push files around between my machines with one command. Now: we can use rsync or scp but /etc/portage is owned by root so we either have to change the permissions to a user we use to ssh or a group that user is in.

Portage users

First change portage permissions of /etc/portage, now all users in the portage group will be able to modify the configuration

1
2
chown -R root:portage /etc/portage
chmod -R g+w /etc/portage

Synchronizing

We can do a rsync from different machine with:

1
rsync -r /etc/portage REMOTEHOST:/etc --exclude=".git" --exclude="make.profile" --copy-unsafe-links

Reminder that this can also be done as a cron job!

Portage snapshots with git

Probably the best thing I got out of genlica is that I engineered a script to automatically do a git commit of the changes to the portage configuration.

Emerge git

1
emerge --noreplace --verbose dev-vcs/git

Copy the file that does the snapshots

1
2
mkdir -p /etc/portage/postsync.d
curl -o /etc/portage/postsync.d/99-degitmerge.sh "https://gitlab.com/xgqt/genlica/-/raw/master/portage/postsync.d/99-degitmerge.sh"