Solved [XFCE] Shutdown & Reboot options disabled

From numerous web and forum searches, there is a lot of traffic on the subject but no definitive solutions.
However, I've made a bit of progress on the subject and I think I need to report observations if only to encourage a fix for everyone.

Situation:
  • AMD Bulldozer running Virtualbox 6.1.6.
  • Install latest FreeBSD-12.1 w/ freebsd-update completed.
  • Followed instructions from Handbook and FreeBSDFoundation How-To for installing xorg and xfce.
  • Includes change of /etc/rc.conf with dbus_enable="YES"
  • Ensured there was a shutdown.rules file (discussed in other posts) and had correct ownership/permissions (polkitd:wheel and 0664)
  • Ensured user was in correct groups as recommended in links above.
  • installed slim w/ recommend change to /etc/rc.conf
After a reboot and login, I had an xfce desktop. However, only option available was to logout. No matter what I did, I was unable to enable the shutdown or restart buttons on the dialog. Another web search and I tripped over this thread from user w5plt who described his problems in 2018.

There was similarities and his solution didn't work for me. I didn't have any hardening enabled with install (confirmed by reviewing /etc/sysctl.conf. However, there were little nuggest of usefulness and gave me ideas on things to try to fix.

That forum post talked about using xfce4-power-manager to diagnosis the problem.
It was weird to discover that for FreeBSD-12.1 the xfce4-power-manager application isn't installed as part of the meta-pkg for xfce. I did a manual install of the package.

Dump of xfce4-power-manager:
Code:
user@machine:~ % xfce4-power-manager --no-daemon --dump
---------------------------------------------------
Xfce power manager version 1.6.6
With policykit support
Without network manager support
---------------------------------------------------
Can suspend: False
Can hibernate: False
Authorized to suspend: False
Authorized to hibernate: False
Authorized to shutdown: False
Has battery: False
Has brightness panel: False
Has power button: True
Has hibernate button: True
Has sleep button: True
Has battery button: True
Has LID: True

I also experimented, as suggested in forum post, with how xfce4 was started.
If I login via slim, regardless of the contents of ~/.xinitrc, there is no change. Shutdown and Restart are still disabled. Logging out there are a pile of error messages on tty0. Again, this is a stock install.

If I changed ~/.xinitrc from handbook recommended:
Code:
. /usr/local/etc/xdg/xfce4/xinitrc
...to this as suggested in the forum...
Code:
exec /usr/local/bin/startxfce4 --with-ck-launch

... and do a startx, I get shutdown and reboot enabled.

Dump of xfce4-power-manager at the time showed:
Code:
user@machine:~ % xfce4-power-manager --no-daemon --dump
---------------------------------------------------
Xfce power manager version 1.6.6
With policykit support
Without network manager support
---------------------------------------------------
Can suspend: False
Can hibernate: False
Authorized to suspend: True
Authorized to hibernate: True
Authorized to shutdown: True
Has battery: False
Has brightness panel: False
Has power button: True
Has hibernate button: False
Has sleep button: True
Has battery button: True
Has LID: True

Something has changed upstream. Now the task at hand seems to be to figure out what the heck the did and implement a repeatable install process.
Suggestions welcomed on how to get xfce to play nice.
 
Just to be clear, Xfce runs fine on FreeBSD, and session management has been improved with the latest release (4.14).

xfce4-power-manager is not mandatory for logout, reboot and so on.

1. Load DBus in /etc/rc.conf
Code:
[...]

dbus_enable="YES"

Hal is not used by Xfce for a long time.

2. Create .rules as suggested in x11-wm/xfce4-session. No need to change permission.
Polkitd load rules files in lexical order, so your own rules (permission for reboot, logout, hibernate, ...) must have a prefix lower than 50-default.rules.

3. Tell to login manager which desktop you want to load
By default it is x11/lightdm, it depends of org.freedesktop.DisplayManager.AccountsService.

3.1. Create (or edit if this file already exists) /var/db/AccountsService/users/your_login (replace your_login, with name of your login).

Code:
[User]
Language=fr_FR.UTF-8
XSession=xfce
SystemAccount=false

You must define the Language variable (and it must be UTF-8 compatible, LightDM works only this encoding type).

XSession variable is very important, (its value is file found in /usr/local/share/xsession). You can define Session too.

If you want to use x11/slim (not maintained, be careful).

3.2. Copy xinitrc in your $HOME
Code:
cp /usr/local/etc/xdg/xfce4/xinitrc ~/.xinitrc
and make sure this file is executable

You can define LC_CTYPE and LANG variables. This file checks and loads another variables used by the Xfce desktop.

Adjust Slim's configuration relative to this file.
 
I forgot, if you want to load your session through startx, .xinitrc is required.

Stop to create your own .xinitrc file! Xfce is the only one desktop which provides this file (with support of ConsoleKit).
 
Can't you
exec startxfce4 ?

No, and no! The best practice is to re-use xinitrc or load xfce.desktop.

Your user must be member of operator group (it is also checked internally by xfce4-session, this feature is common with others BSD).

So, in order to have every buttons active:
1. Enable DBus
2. Add your member in operator group (don't forget wheel too!)
3. Create your own rules (with prefix lower than 50-)
 
2. Create .rules as suggested in x11-wm/xfce4-session. No need to change permission.
Polkitd load rules files in lexical order, so your own rules (permission for reboot, logout, hibernate, ...) must have a prefix lower than 50-default.rules.
x11-wm/xfce4-session is new to me. This may be the missing piece that isn't included in the handbook/how-to's.

3. Tell to login manager which desktop you want to load
By default it is x11/lightdm, it depends of org.freedesktop.DisplayManager.AccountsService.
3.1. Create (or edit if this file already exists) /var/db/AccountsService/users/your_login (replace your_login, with name of your login).

Code:
Language=fr_FR.UTF-8
XSession=xfce
SystemAccount=false
You must define the Language variable (and it must be UTF-8 compatible, LightDM works only this encoding type).

XSession variable is very important, (its value is file found in /usr/local/share/xsession). You can define Session too.

If you want to use x11/slim (not maintained, be careful).

x11/slim is brought up in numerous forum posts as a go to replacement for xdm. I wasn't aware of its development state.
x11/lightdm, it is. And again, this is new stuff not mentioned in references.

So, in order to have every buttons active:
1. Enable DBus
2. Add your member in operator group (don't forget wheel too!)
3. Create your own rules (with prefix lower than 50-)
  1. dbus_enable is already set in /etc/rc.conf
  2. user is a member of the operator group
  3. rules file is named 05-shutdown.rules

I did not use hald reference. I've done that in the past but I didn't see it listed in handbook to add so didn't do that.
I'll look through the setup of x11-wm/xfce4-session and AccountServices. Will report back.
 
And it works...but not as suggested above.
Steps I followed (and for others who end up here from searches):
  1. standard install - watch out for hardening features as discussed in solution of this forum post.
  2. install x11/xorg and configure as shown in How-To (do not use xfce instructions) and Handbook(w/o x11/xdm)
  3. install x11-wm/xfce4, x11/lightdm, and x11/lightdm-gtk-greeter
  4. edit /etc/rc.conf
    Code:
    dbus_enable="YES"
    lightdm_enable="YES"
  5. add user to "operator" group with pw groupmod operator -m user
  6. create polkit shutdown file /usr/local/etc/polkit-1/rules.d/05-shutdown.rules
    Code:
    polkit.addRule(function (action, subject) {
    if ((action.id == "org.freedesktop.consolekit.system.restart" ||
    action.id == "org.freedesktop.consolekit.system.stop") &&
    subject.isInGroup("operator")) {
    return polkit.Result.YES;
    }
    });
  7. AS USER (very important) - cd to home folder and create ~/.xinitrc as shown in the Handbook for xfce (5.7.3)
  8. Although Handbook only mentions "xdm", lightdm needs this too!!!! Duplicate ~/.xinitrc to ~/.xsession with cp .xinitrc .xsession
  9. verify that xfce works for that user with startx
  10. verify that shutdown and reboot options are available for that user from menu->logout
  11. reboot -> shiny new desktop with login
Suggestion of manually creating /var/db/AccountsService/users/your_login wasn't necessary on a fresh install.

What appears to be the fix from original post was creation of a ~/.xsession file and substitute x11/lightdm for slim.

Thanks to olivierd and Alain De Vos for throwing in ideas.
 
.xinitrc and .xsession are not required by LightDM. Personnally I removed these files when I switched to this login manager.

As I already says, these files are mandatory if you launch your session via startx.

Instead of duplicate .xinitrc (for .xsession), symlink works fine too.

The AccountsService file allows to have the desktop translated.
 
olivierd - I'm going by what the handbook shows which is to import into the current environment. Without these files setup, boot to login manager/xfce session just doesn't work. And without a session setup, there are phenominal hoops to deal with to get shutdown/reboot to work. Steps I detailed above in my last post seem to be the cleanest, Point A -> Point B, solution to "install a desktop" that I've found so far.

AccountsService file changes sounds like a problem with locale. I could be wrong. I'm not concerned with I18n. The most fuss I have is ensure at least en_GB is utilized. Manual intervention as suggested seems "counter-intuitive" to me and leaves me the impression a dev missed a step in a package somewhere. But that's my €/$0.02.

Symlink of files is a nice touch. A little cleaner too. Nice.
 
Hi, although the thread is marked 'solved', I just thought to add my observations.

I did not have the mentioned issue with my Xfce+lightdm setup. I had all buttons (logout, restart, shutdown, suspend, hibernate and switch user) enabled. I did have .xinitrc and .xsession but were pointing to other wm when I used to use startx. I deleted both and can confirm as olivierd mentioned, those two files are not needed if using lightdm. To check, I did fresh install on VM and here is my observations.

1) Install FreeBSD (12.1) + latest patches
2) Install Xorg and xfce
3) Enable Dbus in /etc/rc.conf
4) Login using startx. Noticed only 'Log Out' button available. 'Restart and 'Shutdown' buttons were greyed out.
5) Wrote rules file for wheel group to which I added my account. I named 40-shutdown.rules, as olivierd mentioned to have prefix lower than 50-default.conf. Noticed the restart and shutdown buttons were immediately enabled, even without logging out/restarting. Tested both buttons and found functional.
6) Installed lightdm and lightdm-gtk-greeter
7) Enabled lightdm in /etc/rc.conf, removed rules file and rebooted.
8) Booted to lightdm screen, logged into xfce session and found all buttons enabled, even without rules file or .xinitrc, .xsession files.
 
Last edited by a moderator:
And it works...but not as suggested above.
Steps I followed (and for others who end up here from searches):
  1. standard install - watch out for hardening features as discussed in solution of this forum post.
  2. install x11/xorg and configure as shown in How-To (do not use xfce instructions) and Handbook(w/o x11/xdm)
  3. install x11-wm/xfce4, x11/lightdm, and x11/lightdm-gtk-greeter
  4. edit /etc/rc.conf
    Code:
    dbus_enable="YES"
    lightdm_enable="YES"
  5. add user to "operator" group with pw groupmod operator -m user
  6. create polkit shutdown file /usr/local/etc/polkit-1/rules.d/05-shutdown.rules
    Code:
    polkit.addRule(function (action, subject) {
    if ((action.id == "org.freedesktop.consolekit.system.restart" ||
    action.id == "org.freedesktop.consolekit.system.stop") &&
    subject.isInGroup("operator")) {
    return polkit.Result.YES;
    }
    });
  7. AS USER (very important) - cd to home folder and create ~/.xinitrc as shown in the Handbook for xfce (5.7.3)
  8. Although Handbook only mentions "xdm", lightdm needs this too!!!! Duplicate ~/.xinitrc to ~/.xsession with cp .xinitrc .xsession
  9. verify that xfce works for that user with startx
  10. verify that shutdown and reboot options are available for that user from menu->logout
  11. reboot -> shiny new desktop with login
Suggestion of manually creating /var/db/AccountsService/users/your_login wasn't necessary on a fresh install.

What appears to be the fix from original post was creation of a ~/.xsession file and substitute x11/lightdm for slim.

Thanks to olivierd and Alain De Vos for throwing in ideas.
Hi, I have the same issue. The shutdown and restart buttons are inactive. Only logout button is active. But this does not happen all the time. I have XFCE+Slim would I need to do the same please. Is this some type of hardware compatibility issue.?

Thanks & Best Regards
Michael
 
Back
Top