quinta-feira, 30 de abril de 2026

Creating a custom menu in openbox WM

    Hi, folks. It's been a while, isn't it?

    Well, I know nowadays people are telling X11 will be dead soon and the future is Wayland, but for the ones like me, dinosaurs that can't live without things like fluxbox or openbox, how the future will be? 

    Openbox is a very mature WM, offering some tricks we don't see much around here.

    Here's one much helpful: Making custom menus. 

    I've already shown the path to do the same in fluxbox in the past. 

    Now I show you all to do that in openbox.

    First, locate in rc.xml the block of code that refers the menu. It's something like this:

<menu>

    <hideDelay>250</hideDelay>

    <middle>no</middle>

    <submenuShowDelay>100</submenuShowDelay>

    <submenuHideDelay>400</submenuHideDelay>

    <applicationIcons>yes</applicationIcons>

    <manageDesktops>yes</manageDesktops>

    <file>menu.xml</file>

  </menu>

    My suggestion is to duplicate the code but creating a new menu in the tag <file>. Something like this:

<menu>

    <hideDelay>250</hideDelay>

    <middle>no</middle>

    <submenuShowDelay>100</submenuShowDelay>

    <submenuHideDelay>400</submenuHideDelay>

    <applicationIcons>no</applicationIcons>

    <manageDesktops>yes</manageDesktops>

    <file>/home/pibarnas/.config/openbox/custom.xml</file>

  </menu>

    Don't forget to associate a keybind key to call your future menu, into the rc.xml too:

<keybind key="W-c">

      <action name="ShowMenu">

        <menu>custom</menu>

      </action>

    </keybind> 


    Now, in $HOME/.config/openbox, create the file custom.xml, following the rules to make openbox menus (openbox menus):

    Always starting with 

<?xml version="1.0" encoding="utf-8"?>

<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/ file:///usr/share/openbox/menu.xsd">

    And finish with:

          </openbox_menu>


    In mine, the contents are like this:

<?xml version="1.0" encoding="utf-8"?>

<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/ file:///usr/share/openbox/menu.xsd">

<menu

  id="custom"

  label="custom"

>

<item

  label="Music"

>

  <action

    name="Execute"

  >

  <execute>sakura -x /home/pibarnas/bin/music.sh -h</execute>

  </action>

</item>

<item

  label="Vim"

>

  <action

    name="Execute"

  >

  <execute>/opt/appimages/vi</execute>

  </action>

</item>

<item label="_backup OB files">

                <action name="Execute">

                    <prompt>

                        Fazer backup das configs?

                    </prompt>

                    <execute>

                        /home/pibarnas/bin/bkp_openbox2.sh

                    </execute>

                </action>

            </item>

            <item label="Edit Backup">

                <action name="Execute">

                    <execute>

    /opt/appimages/vi /home/pibarnas/bin/bkp_openbox2.sh

                    </execute>

                </action>

            </item>


<menu

  id="Sair"

  label="Sair"

>

<item

  label="Reiniciar"

>

        <action name="Execute">

          <command>/usr/bin/systemctl reboot</command>

        </action>

      </item>

<item

  label="Desligar"

>

        <action name="Execute">

          <command>/usr/bin/systemctl poweroff</command>

        </action>

      </item>


</menu>

</menu>

</openbox_menu>

    That's it! Apart from the root menu, now I have a custom menu that's shown when I press Windows key+"c". You can make several openbox menus, each one with some functionality (a menu to close the session, for instance). Mine's like this:


    

    Only to show you the difference, my root menu is like this:



         That's all folks! Hope you enjoy this tip!




sábado, 24 de novembro de 2018

Window list in Fluxbox

One of the best features on openbox comes "hidden" in Fluxbox. To use it, put a line in your "keys" (/home/"user"/.fluxbox/keys) file like that:

Mod4 Escape    :ClientMenu

In my case, when I click windows button+escape I get:






That's it!

Creating a Custom Shutdown Menu in Fluxbox

This is easy.

Just edit fluxbox "keys" inserting a line like that:

Mod4 x  :CustomMenu "path-to-menu"

Of course the menu you're pointing at must exist in ~/.fluxbox.

In my case, I've done that:

$ touch /home/pibarnas/.fluxbox/sair

$   echo "[begin] (Sair) \n \t [exit] (Sair) {Exit} \n \t [exec] (Desligar) {/sbin/shutdown -h now} \n \t [exec] (Reiniciar) {/sbin/shutdown -r now} \n [end]" > /home/pibarnas/.fluxbox/sair

$ cat /home/pibarnas/.fluxbox/sair

[begin] (Sair)
         [exit] (Sair) {Exit}
         [exec] (Desligar) {/sbin/shutdown -h now}
         [exec] (Reiniciar) {/sbin/shutdown -r now}
 [end]

My ~/.fluxbox/keys related line:

 Mod4 x  :CustomMenu /home/pibarnas/.fluxbox/sair


Now when I click windows button+x this menu appear:





You can make custom menus other than the default one as you wish. Hope you like the tip!



terça-feira, 5 de maio de 2015

Append suffix in linux file names with Shell Parameter Expansion

Well, everytime I read about shell (bash) parameter expansion I see examples ripping off the suffixes. But someday, I needed to do the inverse: Append suffixes. How to do that?

I've made a simple bash script to do so:

#!/bin/bash
for i in *; do 
mv ${i} ${i}.sh;
done
exit 0


Using a for loop, I moved every file in the directory to the same name, with a ".sh" appended as suffix.

Feel free to change the suffix you want.

To revert:

#!/bin/bash
for i in *; do
mv ${i} ${i/.sh/};
done
exit 0

In this case, in every file of the directory, ".sh" will be substituted for nothing. It may cause some troubles. Let's suppose you have a dir, full of these files:

1.shellvpower
2.shellvpower
3.shellvpower
4.shellvpower

They'll become:

1ellvpower
2ellvpower
3ellvpower
4ellvpower

So, in a better way, to remove only the suffixes ".sh":

for i in *; do 
mv ${i} ${i%%\.sh};
done
exit 0

Bonus:

Append prefixes:

To append, for instance, prefix "waka":

#!/bin/bash
for i in *; do
mv ${i} ${i/#/waka};
done

Tip: "#" is before "i" (so,  prefix). "%" would be after "i".

It also can be done in a simpler way:

#!/bin/bash
for i in *; do
mv ${i} waka${i};
done


That's all, folks!! 

terça-feira, 17 de março de 2015

Ultimate Guide for good Looking Fonts on Opensuse (13.2) - without Infinality

Well, as I'm using opensuse 13.2 as OS in one of my disks, let's see how we can improve the look of its horrible fonts.

First: Yast2>/etc/sysconfig editor>Desktop, as seen below: 



Play with font configs in each field. Mine I set as below:

FORCE_HINTSTYLE: hintfull
FORCE_AUTOHINT: yes
FORCE_BW: no
FORCE_BW_MONOSPACE: no
USE_LCDFILTER: lcddefault
USE_RGBA: rgb

These settings will make the links on /etc/fonts/conf.d, disabled by default on opensuse. Other way to make this, as root:

cd /etc/fonts/conf.d/
ln -s /usr/share/fontconfig/conf.avail/10-autohint.conf
ln -s /usr/share/fontconfig/conf.avail/10-sub-pixel-rgb.conf
ln -s /usr/share/fontconfig/conf.avail/11-lcdfilter-default.conf


Make a file named user.js in  $HOME/.mozilla/firefox/*.default/ with this content:

user_pref("font.FreeType2.enable", "true");
user_pref("font.FreeType2.autohinted", "true");
user_pref("font.FreeType2.printing", "true");
user_pref("font.FreeType2.unhinted", "false");


To improve fonts and other enhancements on firefox, I use the excellent ArchWiki, mainly for dpi adjustments (I'm not a fanboy of just one distro but since I'm linux user since 1997, I understand distros are just some kind of free expression to get the same thing, like religions, and btw I used arch, made good friends and learn a lot from some years because of the experience, but the rolling release model doesn't fit on the plans of my server). Here's the link: Firefox tweaks on ArchWiki

Add some related lines to Xdefaults, if it doesn't have:

echo -e "Xft.autohint: 1\nXft.lcdfilter: lcddefault\nXft.hintstyle: hintfull\nXft.hinting: 1\nXft.antialias: 1\nXft.dpi: 144\nXft.rgba: rgb" >> ~/.Xdefaults

As I use a 1920x1080 monitor resolution, I use dpi=144, so pay attention to this set on .Xdefaults above and set accordingly to your own set.

And because of that, I made a xrandr.desktop to set dpi through xrandr as well, to autostart in LXDE:

[Desktop Entry]
Name=Xrandr
Terminal=true
Type=Application
Exec=xrandr --dpi 144


In lxappearance (LXDE), I set like this:



Result:











That's all. I hope this simple tuto helps the other Opensuse users with the bad looking fonts on this great distro (IMHO).   



sexta-feira, 7 de março de 2014

Autostarting apps with LXDE

In a term:

#touch .config/lxsession/LXDE/autostart
#cat .config/lxsession/LXDE/autostart
@pcmanfm

Now, LXDE will load pcmanfm on its start. Simply put what you want on the lines (apps), just remembering to put "@" before entry.

That's it!

Adding sound to LXDE start

Simple.

Make a .desktop file and put it in ~/.config/autostart (if this dir doesn't exist, then create it):
# mkdir ~/.config/autostart
#touch ~/.config/autostart/sound.desktop

As you see, my file's named sound.desktop

Which contents may be:

[Desktop Entry]
Name=Sound
Terminal=true
Type=Application
Exec=mplayer /home/pibarnas/Downloads/221359__melliug__newmessage.mp3

I've downloaded mine from freesound.org. There's a lot of sounds there. Enjoy!