Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there any way to completely disable the .xsession-errors file? I have it as a symlink to /tmp so that my laptop hard disk can (hopefully) go to sleep for once, but at least 95% of the stuff in the file (it fills up at about 500k an hour) is...

(nautilus:1618): GLib-GObject-CRITICAL **: g_value_get_object: assertion `G_VALUE_HOLDS_OBJECT (value)' failed

which is total garbage to me. I have tried doing a symlink to /dev/null but that does not work (the resulting link is overwritten), and I also do not want the activity so that hopefully my laptop can go to sleep for once.

I am using Ubuntu 11.04, with no special add-ons to Nautilus.

share|improve this question
    
That trick does not work for me, because on startup /etc/X11/Xsession does not check what the symbolic link is pointing to. For me it creates a new .xsession-errors regular file, and has .xsession-errors.old linked to /dev/null. That is not what I want. I want .xsession-errors redirected to /dev/null - permantently unless I explicitly change it myself. –  bjem Jan 8 '12 at 4:38
    
Just to clarify @j-johan-edwards. I tested your command and it works fine, I just want it to be permanent. –  bjem Jan 8 '12 at 4:43
    
Does 11.04 use GDM or LightDM as its display manager? –  detly Jan 8 '12 at 5:41
    
I think mine is GDM, if that is the default. I have not changed it except to get away from the Unity desktop. –  bjem Jan 8 '12 at 10:21
    
Yes, my one is GDM. Apparently the path to .xsession-errors is hard coded(?!) into its source code. Is there a good way to run a script after GDM loads to redirect .xsession-errors to /dev/null? –  bjem Jan 11 '12 at 2:36

2 Answers 2

I found an interim solution.

I put a small script in /etc/X11/Xsession.d called 91redirect-xsession-errors that does the job for now, but if you want to have your own custom symlink for .xession-errors it does not work for that (I tried and it did not output any data).

#!/bin/sh

# Redirect $HOME/.xsession-errors to /dev/null.
# BJEM 11 January 2012

XSESSION_ERRFILE=$HOME/.xsession-errors

# This does not seem to work for a regular file,
# i.e. if you want to symlink $HOME/.xsession-errors
# to another file.  I do not know why.
XSESSION_ERRFILE_FINAL=/dev/null

# Creates target file if it does not exist.
touch "$XSESSION_ERRFILE_FINAL"

# Link .xsession-errors file to the desired target
# no matter what.
ln -sf "$XSESSION_ERRFILE_FINAL" "$XSESSION_ERRFILE"

# Test case.
#gedit &

##### END OF FILE #####

It's a bit 'rough and ready' but it does the job for me. Note that this is the only file that has been altered.

share|improve this answer
    
Still works fine in 12.04 and still no attention to problem from developers AFAIU. –  int_ua Jul 5 '12 at 8:34

There is a file called /etc/X11/Xsession. Which will create the symlink to a tmp file. IE. Starts on line number 61

ERRFILE=$HOME/.xsession-errors

# attempt to create an error file; abort if we cannot
if (umask 077 && touch "$ERRFILE") 2> /dev/null && [ -w "$ERRFILE" ] &&
  [ ! -L "$ERRFILE" ]; then
  chmod 600 "$ERRFILE"
elif ERRFILE=$(tempfile 2> /dev/null); then
  if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then
    message "warning: unable to symlink \"$TMPDIR/xsession-$USER\" to" \
             "\"$ERRFILE\"; look for session log/errors in" \
             "\"$TMPDIR/xsession-$USER\"."
  fi
else
  errormsg "unable to create X session log/error file; aborting."
fi

You can cp this Xsession file to Xsession.bak. Then go a head and point your ERRFILE to /dev/null IE. Line 83

exec >> /dev/null 2>&1
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.