Thursday, January 7, 2021

Install dmenu from source code on Raspberry Pi

So what is dmenu? dmenu is a dynamic menu for the X Window System and Raspberry Pi runs Linux. It is simple and can manage large numbers of user-defined menu items efficiently. And one more thing you need to install it from the source code so it is a good exercise to learn how to compile a program in Linux.

dmenu configured to show up in the middle of the screen

Software is freely available from suckless.org, and there is also "dwm" windows manager for X, "st" simple terminal, "surf" simple web browser, and more.

dmenu configured to show up on the top of the screen

First, we need to update the system and install dependencies:

sudo apt update
sudo apt install xorg-dev
sudo apt install build-essential
sudo apt install git

Clone dmenu git repo:

git clone https://git.suckless.org/dmenu

Change directory:

cd dmenu

Build and install dmenu:

sudo make install

And we are ready to run dmenu from the terminal and use it. It shows up above on top of the panel. But it is smaller than the panel and there are fever patches that can help us to look better.

Remove compiler output files:

sudo make clean

Removing config.h file helps to apply patches:

sudo rm config.h

Download desired patch:

// numbers
wget https://tools.suckless.org/dmenu/patches/numbers/dmenu-numbers-4.9.diff
patch -p1 < dmenu-numbers-4.9.diff
sudo make install
sudo make clean
sudo rm config.h

// center
wget https://tools.suckless.org/dmenu/patches/center/dmenu-center-20200111-8cd37e1.diff
patch -p1 < dmenu-center-20200111-8cd37e1.diff
sudo make install
sudo make clean
sudo rm config.h

// highlight
wget https://tools.suckless.org/dmenu/patches/highlight/dmenu-highlight-20201211-fcdc159.diff
patch -p1 < dmenu-highlight-20201211-fcdc159.diff
sudo make install
sudo make clean
sudo rm config.h

// line height
wget https://tools.suckless.org/dmenu/patches/line-height/dmenu-lineheight-5.0.diff
patch -p1 < dmenu-lineheight-5.0.diff
sudo make install
sudo make clean
sudo rm config.h

// border
wget https://tools.suckless.org/dmenu/patches/border/dmenu-border-4.9.diff
patch -p1 < dmenu-border-4.9.diff
sudo make install
sudo make clean
sudo rm config.h

With this part of the setup, we are gonna create keybindings for an easy run as a top panel or in the middle of the screen.

Edit Raspberry Pi OS keybindings:

sudo nano /etc/xdg/openbox/lxde-pi-rc.xml

Add this lines in <keyboard> section:

<keybind key="C-S-space">
    <action name="Execute">
        <command>dmenu_run -h 36</command>
    </action>
</keybind>
<keybind key="C-space">
    <action name="Execute">
        <command>dmenu_run -h 30 -c -l 10</command>
    </action>
</keybind>

Now if we press a key combination SHIFT + CTRL + SPACE runs dmenu above the top panel and pressing CTRL + SPACE runs dmenu in the middle of the screen. And that all for this late-night adventure with Raspberry Pi.

Till the next time.

No comments:

Post a Comment