Xfce Xfce4 - shutdown as normal user


I've installed Xfce4 with wdm. When I want to stop my computer completely, I've to do following:
1. Logout from Xfce4 session, there is no possibility to shutdown directly, buttons for shutdown, reboot and suspend are grey.
2. After logout from Xfce4 session I've to choose in wdm halt, then I've to give my username and password.
3. Then FreeBSD stops, but I've to power off machine completely with pressing power button for a few seconds.

Before new installation of FreeBSD with Xfce4 I've had an installation with kde4 and kdm, and there was no problem to power off machine directly under a KDE session.

Kind regards,
Using 10.2-RELEASE.

I did a pkg upgrade which updated Xfce4 to 4.12 yesterday (among other things). Before yesterday, these buttons (shutdown, reboot) were enabled and functioning for my user account. I use startx to launch X and Xfce. I have the ability to shutdown the computer from the shell. After the aforementioned update, these buttons are now "greyed out". I re-added the .rules file described in pkg info -D xfce4-session (the file seemed to have disappeared) and restarted my computer... however these buttons are still greyed out. Other things went haywire in Xfce4 as well after the update, but blowing away all the "dot configuration" directories in my home directory seems to have straightened most of them out. I still have not been able to get the shutdown and reboot buttons functioning again. My .xinitrc looks like this:
xset -dpms
xset s noblank
xset s off
numlockx on
exec /usr/local/bin/startxfce4
Hello emcee,

apart from your issues I've noticed another annoying behavior with xfce-4.12 on two machines. After starting xfce session, which is very fast on computer of my wife and on my computer, filemanager thunar often needs a half minute and more to start. Further issue: When starting another application sometimes it happens, that thunar also starts - a little bit curious. When I begin with FreeBSD I've setup an environement with kde4, and it works like a charme, so I think about to replace xfce stuff with kde4 stuff. I like both desktop environements and in this situation I choose that one without issues.

Kind regards,
emcee, stop to create your own .xinitrc. I know, Handbook is outdated, but it will be updated when Xfce's FAQ will be available (currently we need to fix some sentences).

x11-wm/xfce4-session provides this file. It works out-of box, just copy it into your $HOME. Moreover, it checks some environment variables needed by DBus demon.

Information displays with x11-wm/xfce4-session depends of version of sysutils/polkit

If pkg query %v polkit returns 0.113, you need to write your authorization rules files in JavaScript fashion. These files are not missing.

To allow some actions, here shutdown (stop) /reboot (restart), you can search these actions:

pkaction | grep -E 'stop|restart'

To check, if you can reboot your computer, pkaction --action-id org.freedesktop.consolekit.system.restart --verbose. The permission (here, implicit active, the user is authorized to carry out the action without any authentication during active session) must be enabled, if not you need to authorize such action.

Since 4.12, there's also fallback action (if you don't install sysutils/consolekit), calls org.xfce.session.xfsm-shutdown-helper. It uses shutdown(8) and reboot(8) commands.

To use this action, create file 03-xfsm-shutdown-helper.rules (for example) with this contents:

polkit.addRule(function(action, subject) {
  if (action.id == "org.xfce.session.xfsm-shutdown-helper" && subject.user == "emcee") {
    return polkit.Result.YES;

In above rule I use explicitly one user, not group, result is identical.
Thank you very much for the help! The problem is not yet resolved. I copied the .xinitrc into my home directory from /usr/local/etc/xdg/xfce4/xinitrc. I restarted the system and the xfce buttons for shutdown and restart are still greyed out. I include some commands with output for your examination. Any help is appreciated!

[~]: pkg query %v polkit
[~]: pkaction | grep -E 'stop|restart'
[~]: pkaction --action-id org.freedesktop.consolekit.system.restart --verbose
  description:  Restart the system
  message:  System policy prevents restarting the system
  implicit any:  no
  implicit inactive: no
  implicit active:  yes

[~]: groups
michael wheel operator vboxusers
[~]: cd /usr/local/etc/polkit-1/rules.d
-bash: cd: /usr/local/etc/polkit-1/rules.d: Permission denied
[~]: su -l
root@helix:~ # cd /usr/local/etc/polkit-1
root@helix:/usr/local/etc/polkit-1 # ll
total 8
drwxr-xr-x  7 root  wheel  512 Aug 22 15:35 localauthority/
drwx------  2 polkitd  wheel  512 Oct 10 02:40 rules.d/
root@helix:/usr/local/etc/polkit-1 # cd rules.d
root@helix:/usr/local/etc/polkit-1/rules.d # ll
total 8
-rw-r--r--  1 root  wheel  326 Oct  4 00:05 50-default.rules
-rw-r--r--  1 root  wheel  248 Oct 10 02:40 60-shutdown.rules
root@helix:/usr/local/etc/polkit-1/rules.d # cat 60-shutdown.rules
polkit.addRule(function (action, subject) {
  if (action.id == "org.freedesktop.consolekit.system.restart" ||
  action.id == "org.freedesktop.consolekit.system.stop"
  && subject.isInGroup("wheel")) {
  return polkit.Result.YES;

This is the .xinitrc contents. As an aside, I don't see where xscreensaver is launched.


# fix broken $UID on some system...
if test "x$UID" = "x"; then
  if test -x /usr/xpg4/bin/id; then
  UID=`/usr/xpg4/bin/id -u`;
  UID=`id -u`;

# set $XDG_MENU_PREFIX to "xfce-" so that "xfce-applications.menu" is picked
# over "applications.menu" in all Xfce applications.
if test "x$XDG_MENU_PREFIX" = "x"; then

# set DESKTOP_SESSION so that one can detect easily if an Xfce session is running
if test "x$DESKTOP_SESSION" = "x"; then

# set XDG_CURRENT_DESKTOP so that Qt 5 applications can identify user set Xfce theme
if test "x$XDG_CURRENT_DESKTOP" = "x"; then

# $XDG_CONFIG_HOME defines the base directory relative to which user specific
# configuration files should be stored. If $XDG_CONFIG_HOME is either not set
# or empty, a default equal to $HOME/.config should be used.
if test "x$XDG_CONFIG_HOME" = "x" ; then
[ -d "$XDG_CONFIG_HOME" ] || mkdir "$XDG_CONFIG_HOME"

# $XDG_CACHE_HOME defines the base directory relative to which user specific
# non-essential data files should be stored. If $XDG_CACHE_HOME is either not
# set or empty, a default equal to $HOME/.cache should be used.
if test "x$XDG_CACHE_HOME" = "x" ; then
[ -d "$XDG_CACHE_HOME" ] || mkdir "$XDG_CACHE_HOME"

# set up XDG user directores.  see
# http://freedesktop.org/wiki/Software/xdg-user-dirs
if which xdg-user-dirs-update >/dev/null 2>&1; then

# Modify libglade and glade environment variables so that
# it will find the files installed by Xfce

# For now, start with an empty list

# Has to go prior to merging Xft.xrdb, as its the "Defaults" file
test -r "/usr/local/etc/xdg/xfce4/Xft.xrdb" && XRESOURCES="$XRESOURCES /usr/local/etc/xdg/xfce4/Xft.xrdb"
test -r $HOME/.Xdefaults && XRESOURCES="$XRESOURCES $HOME/.Xdefaults"

if test -r "$BASEDIR/Xft.xrdb"; then
elif test -r "$XFCE4HOME/Xft.xrdb"; then
  mkdir -p "$BASEDIR"
  cp "$XFCE4HOME/Xft.xrdb" "$BASEDIR"/

# merge in X cursor settings
test -r "$BASEDIR/Xcursor.xrdb" && XRESOURCES="$XRESOURCES $BASEDIR/Xcursor.xrdb"

# ~/.Xresources contains overrides to the above
test -r "$HOME/.Xresources" && XRESOURCES="$XRESOURCES $HOME/.Xresources"

# load all X resources (adds /dev/null to avoid an empty list that would hang the process)
cat /dev/null $XRESOURCES | xrdb -nocpp -merge -

# load local modmap
test -r $HOME/.Xmodmap && xmodmap $HOME/.Xmodmap

# run xfce4-session if installed
if which xfce4-session >/dev/null 2>&1; then

  # check if we start xfce4-session with ck-launch-session. this is only
  # required for starting from a console, not a login manager
  if test "x$XFCE4_SESSION_WITH_CK" = "x1"; then
  if which ck-launch-session >/dev/null 2>&1; then
  ck-launch-session xfce4-session
  echo "You have tried to start Xfce with consolekit support, but"
  echo "ck-launch-session is not installed."
  echo "Aborted startup..."

  exit 1
  # start xfce4-session normally

  exit 0


# Everything below here ONLY gets executed if you are NOT using xfce4-session
# (Xfce's session manager).  If you are using the session manager, everything
# below is handled by it, and the code below is not executed at all.  If you're
# not sure if you're using the session manager, type 'ps -e|grep xfce4-session'
# in a terminal while Xfce is running.


# Use dbus-launch if installed.
if test x"$DBUS_SESSION_BUS_ADDRESS" = x""; then
  if which dbus-launch >/dev/null 2>&1; then
  eval `dbus-launch --sh-syntax --exit-with-session`
  # some older versions of dbus don't export the var properly
  echo "Could not find dbus-launch; Xfce will not work properly" >&2

# this is only necessary when running w/o xfce4-session
xsetroot -solid black -cursor_name watch

# or use old-fashioned startup script otherwise

xfsettingsd &
xfwm4 --daemon

# start up stuff in $XDG_CONFIG_HOME/autostart/
if test -d "$XDG_CONFIG_HOME/autostart"; then
  for i in ${XDG_CONFIG_HOME}/autostart/*.desktop; do
  grep -q -E "^Hidden=true" "$i" && continue
  if grep -q -E "^OnlyShowIn=" "$i"; then
  # need to test twice, as lack of the line entirely means we still run it
  grep -E "^OnlyShowIn=" "$i" | grep -q 'XFCE;' || continue
  grep -E "^NotShowIn=" "$i" | grep -q 'XFCE;' && continue

  # check for TryExec
  trycmd=`grep -E "^TryExec=" "$i" | cut -d'=' -f2`
  if test "$trycmd"; then
  which "$trycmd" >/dev/null 2>&1 || continue

  cmd=`grep -E "^Exec=" "$i" | cut -d'=' -f2`
  if test "$cmd" && which "$cmd" >/dev/null 2>&1; then
  $cmd &

orage &

panel=`which xfce4-panel`
case "x$panel" in
     while test $ret -ne 0; do
       xmessage -center -file - -timeout 20 -title Error <<EOF
A crash occured in the panel
Please report this to the xfce4-dev@xfce.org list
or on http://bugs.xfce.org
Meanwhile the panel will be restarted
       cat >&2 <<EOF
A crash occured in the panel
Please report this to the xfce4-dev@xfce.org list
or on http://bugs.xfce.org
Meanwhile the panel will be restarted

xsetroot -bg white -fg red  -solid black -cursor_name watch
Try to rename your file, usually I put lower priority than 50 (05).

In fact x11/xscreensaver is automatically launches (if it's present), because there's .desktop file in autostart/ directory. I confused with another script, sorry.
I renamed the file and restarted the system. The shutdown and restart buttons remain greyed out. Here are some commands and output which might help in troubleshooting. I appreciate the help!

One additional thing... I did a fresh install of 10.2 release in a virtual machine. Then I installed and setup xfce4... The problem exists in this newly installed virtual machine as well.

root@helix:/usr/local/etc/polkit-1/rules.d # ll
total 8
-rw-r--r--  1 root  wheel  248 Oct 10 02:40 05-shutdown.rules
-rw-r--r--  1 root  wheel  326 Oct  4 00:05 50-default.rules

root@helix:/usr/local/etc/polkit-1/rules.d # cat 05-shutdown.rules
polkit.addRule(function (action, subject) {
  if (action.id == "org.freedesktop.consolekit.system.restart" ||
  action.id == "org.freedesktop.consolekit.system.stop"
  && subject.isInGroup("wheel")) {
  return polkit.Result.YES;

root@helix:/usr/local/etc/polkit-1/rules.d # pkg info | grep xfce
gtk-xfce-engine-3.2.0  Xfce GTK2 theme engine
libxfce4gui-4.10.0_5  Various Gtk widgets for the Xfce Desktop
libxfce4menu-4.12.1_1  Widgets library for the Xfce desktop environment
libxfce4util-4.12.1  Extension library for the Xfce desktop environment
xfce-4.12_1  The "meta-port" for the Xfce Desktop Environment
xfce4-appfinder-4.12.0  Application launcher and finder
xfce4-conf-4.12.0  D-Bus-based configuration storage system
xfce4-desktop-4.12.3  Xfce's desktop manager
xfce4-genmon-plugin-3.4.0_5  Generic Monitor Xfce4 panel plugin
xfce4-mixer-4.11.0_3  Volume control for the Xfce desktop
xfce4-mount-plugin-0.6.7_3  Mount and umount utility for the Xfce4 panel
xfce4-notifyd-0.2.4_1  Visually-appealing notification daemon for Xfce
xfce4-panel-4.12.0_1  Xfce's panel
xfce4-print-4.6.1_13  Print system support for the Xfce Desktop
xfce4-screenshooter-plugin-1.8.2_2 Application and panel plugin to take screenshots
xfce4-session-4.12.1_2  Xfce's session manager
xfce4-settings-4.12.0_1  Xfce 4 settings application
xfce4-taskmanager-1.1.0_1  Task manager for the Xfce desktop
xfce4-terminal-0.6.3_2  Terminal emulator for the X windowing system
xfce4-tumbler-0.1.31_1  Thumbnail service for Xfce desktop
xfce4-whiskermenu-plugin-1.5.1 Alternate menu for the Xfce Desktop
xfce4-wm-4.12.3  Xfce's window manager
xfce4-wm-themes-4.10.0_1  Additional themes for xfwm4

root@helix:/usr/local/etc/polkit-1/rules.d # pkg info | grep polkit
polkit-0.113_1  Framework for controlling access to system-wide components

root@helix:/usr/local/etc/polkit-1/rules.d # pkg update
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.

root@helix:/usr/local/etc/polkit-1/rules.d # pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
Checking for upgrades (1 candidates): 100%
Processing candidates (1 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.
I had the same issue as being not able to reboot/shutdown as $ even though part of wheel & operator groups, but thanks to protocelt 's fix # chown polkitd:wheel /usr/local/etc/polkit-1 this now works, but unfortunately not all the time. Sometimes suddenly the permission seems to get lost "on-the-fly", because when I try to shutdown/reboot after a desktop session suddenly the buttons are grayed out again. Doesn't matter how long I'm using the desktop and after a reboot via terminal it works again. Any idea how this can happen?
It wasn't my fix. I merely linked to the PR that mentioned a fix. :)

This doesn't make much sense to me. When having this problem, did you check the permissions on the directory to see if they were indeed wrong/changed?

I do see PR 202615 is still open, so it's possible that during port updates the permissions are changed back again depending on what's been updated, though that wouldn't be the case here as you say it works again if you reboot.
Sorry for bringing this up, but the issue is still relevant. The options are greyed out for me, and I did every single trick listed here (Or I think so)
Here's some additional information.

This is a fresh freebsd 10.3 install on x220 laptop with XDM + XFCE set up as per Freebsd Handbook.

I've copied .xinitrc from /usr/local/etc/xdg/xfce4/xinitrc to my ~/.xinitrc

pkg query %v polkit returns 0.113_1

This concerns me:
pkaction | grep -E 'stop|restart'
Error getting authority: Error initializing authority: Could not connect: No such file or directory

Permissions look ok to me:
[par@x220 ~]$ groups
par wheel

[par@x220 ~]$ ls -la /usr/local/etc/polkit-1/
total 26
drwxr-x---  4 polkitd  wheel  4 May 22 02:25 .
drwxr-xr-x  29 root  wheel  45 Jun  6 12:12 ..
drwxr-xr-x  7 root  wheel  7 May 30 23:15 localauthority
drwxr-x---  2 polkitd  wheel  5 Jun  7 23:25 rules.d

[par@x220 ~]$ ls -la /usr/local/etc/polkit-1/rules.d/
total 23
drwxr-x---  2 polkitd  wheel  5 Jun  7 23:25 .
drwxr-x---  4 polkitd  wheel  4 May 22 02:25 ..
-rw-r--r--  1 root  wheel  248 Jun  7 22:21 05-shutdown.rules
-rw-r--r--  1 root  wheel  326 May 22 02:25 50-default.rules

Any guidance for a new FreeBSD user would be appreciated ;)
Hey Olivier,

Thank you for putting me on the right track. Although I did have some bumps I managed it in the end :)

I did switch from XDM to SLIM, and the next thing I had was black screen after logging in via SLIM
I then found out about dbus_enable="YES" in /etc/rc.conf. Nowhere was it mentioned in the Freebsd handbook, so it was new to me.

I assume the initial problem was absence of dbus, and this is why those options were greyed out.
I tried XDM with dbus enabled - did not work, but I assume the patch mentioned in your link would solve that issue.