pkexec - Mousepad-ERROR **: Cannot open display (

I was trying to implement some actions in Thunar , following their site : xfce:thunar:custom-actions [Xfce Docs]

But I get this error where no X is found… or session… not sure.
Basically it would be simple :

Editing as root

  • Name: Edit as root
  • Command: gksu put-your-favourite-text-editor-here %f
  • File pattern: *
  • Appears if selection contains: Text files

There is no gksu , so the pkexec is the replacement for that command.
There’s no errors running that command in thunar, but nothing happens.
So in a terminal , I’ve try those commands , and I get this errors :

daniel@linux-7ya6:~/Documents> pkexec mousepad info.php 
(mousepad:17064): Mousepad-ERROR **: Cannot open display: 

Or sudo mousepad or pkexec --user root mousepad

Is there something to config in the system to open a X display … I mean, other applications use it.

If this is achievable , thunar it’s great


Even If I make a sudo -E mousepad I get a lot of errors such as :

(mousepad:20366): GtkSourceView-CRITICAL **: gtk_source_style_scheme_get_id: assertion 'GTK_IS_SOURCE_STYLE_SCHEME (scheme)' failed

(mousepad:20366): GtkSourceView-CRITICAL **: gtk_source_style_scheme_manager_get_scheme: assertion 'scheme_id != NULL' failed

(mousepad:20366): GtkSourceView-CRITICAL **: gtk_source_style_scheme_get_id: assertion 'GTK_IS_SOURCE_STYLE_SCHEME (scheme)' failed

They do not happen using leafpad
But anyway , this doesn’t seems to work in thunar actions.

I got this far, googling , in a ubuntu forum :

Creating this alias in .bashrc , I can now execute pkexec in a terminal .


But , in thunar , I still get no results.
That forum, talks in creating a custom policy in /usr/share/polkit-1/

There’s actually a application in xfce panel, call Ice-Tea-Web-policy , but , I not sure if I want to mess around with that.

As for running Thunar as Super User , we have to place in** /usr/share/polkit-1/actions/** a file, called **org.freedesktop.pkexec.thunar.policy

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
  "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"

  <action id="org.freedesktop.pkexec.thunar">
    <message>Authentication is required to run thunar</message>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/thunar</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>


So in a custom action , the** pkexec thunar %f** will work
And, I guess this is something that as to be done for all actions with privileges

For mousepad would be the same… but I get all those errors that I mentioned above, running mousepad… leafpad it’s ok , but I don’t like the search and replace in leaf