From the Terminal

keyd on Gentoo with OpenRC and KDE Plasma

git clone https://github.com/rvaiya/keyd
cd keyd
make && sudo make install
touch /etc/init.d/keyd
nano /etc/init.d/keyd

Pop this in there and save.

#!/sbin/openrc-run

# Description of the service
description="keyd key remapping daemon"

# The location of the keyd binary
command="/usr/local/bin/keyd"
#command_args="-d"
pidfile="/run/keyd.pid"

depend() {
    need localmount
    after bootmisc
}

start() {
    ebegin "Starting keyd"
    start-stop-daemon --start --exec $command --background --user root  --make-pidfile --pidfile $pidfile --
    eend $?
}

stop() {
    ebegin "Stopping keyd"
    start-stop-daemon --stop --pidfile $pidfile
    eend $?
}

restart() {
    ebegin "Restarting keyd"
    start
    eend $?
}
sudo rc-update add keyd default
/etc/init.d/keyd start
sudo setfacl -m u:USERNAME:rw /var/run/keyd.socket

If you want application specific key binds you need to run /usr/local/bin/keyd-application-mapper inside your KDE Plasma session. To do that simply add it to your autostart through the System Settings application.

 

Making Patches for Portage Packages

When you run emerge portage does a series of things to your package in order:

  • fetch
  • unpack
  • prepare
  • compile

To set up a patch working environment we're going to go ahead and let it do all of that up to prepare. We will do this with the ebuild command:

ebuild file.ebuild fetch
ebuild file.ebuild unpack
ebuild file.ebuild prepare

 

Now we copy the work directory to our own directory:

sudo cp -R /var/tmp/portage/www-client/ungoogled-chromium-88.0.4324.150-r2/work ~/Sources/ungoogled-chromium-88.0.4324.150-r2-work
sudo chown -R akujin:users /var/tmp/portage/www-client/ungoogled-chromium-88.0.4324.150-r2/work ~/Sources/ungoogled-chromium-88.0.4324.150-r2-work

 

Now we have our work directory where we can build our patch. The patch will be applied after prepare is done running so that is why we copied the work directory right after prepare was done running. In our copy of the work directory we need to initialize the folder as a git repo so we go ahead and run:

git init
git add .
git commit

 

Now we can make the modifications we want to make. After you're done simply stage your changes and run:

sudo sh -c "git diff --staged > /etc/portage/patches/www-client/ungoogled-chromium/macos-hotkeys-on-linux.patch"

 

You can test your new patch simply by running emerge on your package.

Running Multiple Instances of Discord in Linux

In Linux Discord stores it's data in XDG_CONFIG_HOME which is ~/.config by default. It also uses /tmp for a discord.sock file which it uses to determinate if there is already a running process.

Simply set both TMPDIR and XDG_CONFIG_HOME to an alternative and launch discord.

/bin/bash -c "export XDG_CONFIG_HOME=~/.nya; export TMPDIR=~/nya; /opt/discord/Discord"

In Gentoo Discord installs to /opt so change that to your location.

Solving Dependency Slot Conflicts in Gentoo Elegantly

Sometimes when you want to emerge something or upgrade something you will have dependency slot conflicts like this example.

 

To fix this problem you'd need to emerge all kde-frameworks/* packages you currently have installed to upgrade them all at once since it's all part of one framework.

The following commands let you do so with ease.

equery l kde-frameworks/* -F '$category/$name'

 

The output of which you can send right into emerge like so.

sudo emerge --ask -1 --verbose-conflicts $(equery l kde-frameworks/* -F '$category/$name')

 

Now you'll hopefully get a clean emerge.