JWM Part 6 Exiting JWM

Published on October 9, 2021 at 7:51 am by LEW

Introduction

Different ways of Exiting/Restarting the JWM interface is the subject of this post. The default configuration offers two options at the bottom of the menu, Restart and Exit. In my opinion these are both somewhat misleading.

In this article we will modify these two options and add two more. So the bottom of the menu will instead be be Reload, Logout, Restart, and Shutdown.

JWM Exit Optiosn in Menu

JWM Actions

There are several defined actions in JWM that can be attached to various widgets on the desktop. In this case the two we are concerned with are restart and exit. We will discuss other actions when we talk about key bindings in a latter post.

The restart action will cause JWM to reload the configuration file. Existing work and activity will not be lost, but the system configuration file will be reread, and any changes made will become effective.

But be forewarned, if you break the configuration file, you may lock up the Window manager when you execute the restart action.

Note, to avoid this type of issue, when you change the configuration file, you should run jwm -p from the terminal to test the configuration file before you actually use it.

The exit action will cause you to be logged out of JWM. Depending on how your system is setup this will either return you to a Display manager or a command prompt.

Modify Menu Entry

Rather than be in a program statement, actions can be entered directly into the menu structure. For the above examples the entries would look like the following.

<Restart label=”Reload” icon=”reload.png” tooltip=”Restart JWM” />

<Exit label=”Logout” icon=”logout.png” tooltip=”Exit JWM Session” />

Note the ending forward slash, making this a one line entry. The icon file must be in one of the defined icon paths.

Reboot and Shutdown

In the default menu there are no options for either reboot or shutdown. So we will need to add those ourselves by calling the correct program. Depending on how we do this we may or may not have to grant temporary root access. Let me explain.

In most modern Linux distributions, the ability to shut down the system or reboot it is considered a root account action, and normal users can not do it. This comes form the multi user nature of Linux, meaning no user should be able to shut down the system while others are logged on and using it. Now this will generally not apply to a personal computer, as you are probably the only person using it. But it is still part of the Linux operating system.

The standard method to get around this was to use sudo. Sudo is a program that can be setup by the administrator to give normal users elevated privileges and allow them to access some root functions, specifically commands like shutdown.

Interestingly, if you are using systemd, which the current release of Debian at the time of this writing is using, you do not need sudo.

In this case we can create a menu option that calls systemctl poweroff to achieve a shutdown without sudo privileges. We can also use systemctl reboot to restart the system.

Here is an example of how to do it.

<Program icon=”shutdown.png” label=”Shutdown” tool tip=”Turn Off System”>

      systemctl poweroff

</Program>

Conclusion

In this post we covered defining actions in the menu system, as well as using system commands for shutdown and reboot. For other available actions, you will need to check the official JWM setup guide.

Next time, I will discuss key bindings, groups, and a few other miscellaneous items for configuring JWM.

JWM Part 1 Taking Control
JWM Part 2 The Menu
JWM Part 3 Window Color
JWM Part 4 Desktop Background
JWM Part 5 The Tray
JWM Part 6 Exiting JWM
JWM Part 7 Bindings and Groups

sudo.user says:

systemctl does not exist in openrc. How should user shutdown or reboot as sudo or su from jwm.

LEW says:

Thank you for your comment.

While I have not used openrc, I have used system V in the past. There should be a shutdown command in /sbin, which can be run as sudo or su. I believe it is called openrc-shutdown in opnenrc. You can use the –poweroff and –restart options with the command.

Add New Comment

Your email address will not be published. Required fields are marked *