OpenOffice.org 2.4.x Dark Theme Workaround With Ubuntu 8.04
I’d been having issues with colors in OpenOffice.org applications while using a dark GTK2.0 theme for my Gnome environment. OpenOffice.org applications would start in a high contrast mode and would not display the pages with correct coloring. What you would see on the screen could be far different from what you print. Apparently this is a known bug at OpenOffice’s bug tracker, but there’s yet to be a fix. One commenter posts that it still persists in the 3.0 Beta.
The Ubuntu forums had this asked and answered with a workaround, but that broke with the new release of 8.04 Hardy Heron. I couldn’t find an updated workaround and between desperation, aggravation, and a lack of patience, motivation set in and I went about to find one of my own.
Short Overview
First a short lesson. The shell scripts that run all of OO.o’s applications are found in the following directory:
/usr/lib/openoffice/program/
Each of the OO.o applications has its own shell script.
- swriter - OpenOffice.org Word Processor
- scalc - OpenOffice.org Spreadsheet
- sbase - OpenOffice.org Database
- simpress - OpenOffice.org Presentation
- smath - OpenOffice.org Math
- sdraw - OpenOffice.org Drawing
Each of these executes one main shell script, soffice, while passing it an argument that defines what application you’re planning on using. It’s this file we’ll be using in our workaround
In order to tell OO.o what theme to use, we set an environment variable pointing to the gtkrc file of that theme while we execute the script for that program. For instance, the following launches OpenOffice.org Word Processor with Ubuntu’s Human them:
sudo env GTK2_RC_FILES=/usr/share/themes/Human/gtk-2.0/gtkrc /usr/lib/openoffice/program/swriter
Two flaws with this is 1) because you need to use root privileges to set environment variables, you inadvertently run OO.o applications with root privileges as well, and 2) it’s a hassle to have to do this manually. You could edit each of the OO.o shell scripts and include the above environment variables.
#!/bin/sh cmd='dirname "$0"'/soffice exec "$cmd" -writer "$@"
…would become…
#!/bin/sh cmd='dirname "$0"'/soffice exec env GTK2_RC_FILES=/usr/share/themes/Human/gtk-2.0/gtkrc "$cmd" -writer "$@"
But that would be a hassle to change them all back if you change your mind in the future. I thought it best to edit just one.
Workaround
The directions that follow assume that you are running Ubuntu 8.04 with OpenOffice.org 2.4.x installed. The same workaround should work with other distributions as long as directory locations are corrected to match your specific operating system. As donoterase has commented below, his OO.o installation directory is different.
Step 1:
First thing I did was rename the soffice file. Open a terminal and at the command line and just move it.
sudo mv /usr/lib/openoffice/program/soffice /usr/lib/openoffice/program/soffice1
Step 2:
Now, make a new soffice file.
sudo gedit /usr/lib/openoffice/program/soffice
Step 3:
Paste the following shell script code and save the file.
#!/bin/sh env GTK2_RC_FILES=/usr/share/themes/Human/gtk-2.0/gtkrc /usr/lib/openoffice/program/soffice1 "$@"
Step 4:
Next, make it executable.
sudo chmod +x /usr/lib/openoffice/program/soffice
Step 5a:
There are two options for step 5. The quick and easy way is to rename the binary file. The original soffice script sets a basename variable for the binary’s file name based on the script’s file name. Since we renamed the script to soffice1, we need to rename the binary to soffice1.bin. Braver souls can opt for Step 5b.
sudo mv /usr/lib/openoffice/program/soffice.bin /usr/lib/openoffice/program/soffice1.bin
Step 5b:
If you’re comfortable enough, you can edit the line in the original soffice file instead of renaming the binary. While Step 5a works, I’d rather keep the binary name as is just in case there’s a dependency for it which I haven’t come across. Find the following line of code in your now soffice1 file:
sd_binary='basename "$0"'".bin"
Comment that out and add a similar line below and save it.
# sd_binary='basename "$0"'".bin" sd_binary="soffice.bin"
Conclusion
Now, each and every OpenOffice.org app should launch using the Ubuntu Human theme to display the correct layout coloring. I had mixed results when using other themes. Some worked well while others didn’t work at all. The dark theme that I’m using, Overglossed by TheRob, gives me dark-blue panel colors with some themed areas, but high contrast icons. Layout color was incorrect. Slickness-Black, also by TheRob, forces OO.o applications into their default high contrast mode. For myself, I’ll stick with the Human theme so I can enjoy the graphs in my spreadsheets the way they were intended.
Now, this assumes that nothing about your OpenOffice.org installation will change any time soon. This workaround could very well break with a future update to OpenOffice.org. It would be very likely to break between Hardy Heron and Intrepid Ibex. But that’s why we call this a workaround and not a fix.
Keep in mind as with any fixes or workarounds, you do so at your own risk. However, if something needs clarifying, don’t hesitate to ask.
OpenOffice.org 3.0.0
If you were successful with installing OO.o 3.0.0 and would like to apply the above to it, just replace /usr/lib/openoffice/program in the instructions above with /opt/openoffice.org3/program which is default non-Ubuntu installation directory for OO.o 3.0.0.
September 24th, 2008 at 4:13 am
is there a script for it?
September 24th, 2008 at 4:41 am
Hi. After make all tha tasks that you recommend up, my Openoffice is completely out of service. I need help as fast as you can.
September 24th, 2008 at 5:00 am
@ Paul Valley
No, I didn’t make a script for it.
@ Mario
The only place I can see where you might have an issue is in the new /usr/lib/openoffice/program/soffice file…
Because of the way text on this website is formatted, it may appear that the line beneath #!/bin/sh is two lines rather than one word-wrapped line. Make sure you don’t have any carriage returns between env and “$@”
edit: I added a plugin to the site that highlights code and shows it as it should be instead of formatted to look like more lines than it ought to be. That should make those areas clearer. The above quoted line looks better as:
[code lang='sh']
#!/bin/sh
env GTK2_RC_FILES=/usr/share/themes/Human/gtk-2.0/gtkrc /usr/lib/openoffice/program/soffice1 “$@”
[/code]
September 24th, 2008 at 6:17 am
Thank you for your fast help, but the problem is persistence and I dont know what happen. What I can do for fix my Openoffice? Reinstall maybe?
September 24th, 2008 at 6:42 am
Two options to fix your OpenOffice.org is 1) revert your changes or 2) reinstall. The /usr/lib/openoffice/program/soffice file we were changing is part of the openoffice.org-common package. You can issue the following at the command line to restore the original…
[code]sudo apt-get install –reinstall openoffice.org-common[/code]
September 24th, 2008 at 7:06 am
Hello all. There seems to be some confusion with this fix/workaround. It is a fairly straight forward fix, and the only area I can see where problems might arise is the specified directory of OpenOffice. For example,
my openoffice directory is located in /usr/lib/ooo-2.4/program/
Please check where your openoffice installation is located.
September 24th, 2008 at 7:07 am
I run the command line in terminal and all seems works fine, but I cant open the Openoffice yet.
September 24th, 2008 at 7:15 am
@Mario, you may need to rename the bin file back to it’s original.
[code]sudo mv /usr/lib/openoffice/program/soffice1.bin /usr/lib/openoffice/program/soffice.bin[/code]
@donoterase
Is your OO.o install an Ubuntu installation or one from a different distribution/source?
September 24th, 2008 at 7:41 am
I do this, but I cant open the Openoffice yet. I need a “how to” for reinstall completely the Openoffice. Thanks in advance.
September 24th, 2008 at 8:01 am
Well, in my country is the 2:00 am, and I need to sleep, thanks for your efforts to help me. See you later…
September 24th, 2008 at 8:16 am
Mario, I am apprehensive about giving more advice since nothing I have explained has worked for you. I do not know much about your operating system or what you did that broke your OO.o installation. But, my last guess for you is to open Synaptic Package Manager, search for openoffice.org, and mark any installed openoffice.org package (IE: openoffice.org, openoffice.org-base, openoffice.org-base-core, openoffice.org-draw, etc.) for reinstall.
October 5th, 2008 at 10:20 am
Worked like a charm. Thanks Adam.
October 9th, 2008 at 4:35 pm
Thanks!
this worked extremely well, keep the good work up!
October 13th, 2008 at 12:20 am
Nice, this works perfect on my Arch with Open Office 3 :)
October 13th, 2008 at 7:23 pm
Hi everyone…
I try the workaround on Ubuntu Hardy 64-bit and don’t work correctly.
The theme changes but not for the Human theme, actually, I don’t know what theme is.
I’m sure that I followed the instructions corectly but I don’t know.
Is that a 64-bit dependant issue?
Please, help…
October 14th, 2008 at 8:21 pm
@ ArCeSiNo
First, no, this workaround is not dependent upon 32 or 64-bit install. It should work for either.
However, and this brings me to my second point, I want to thank-you for commenting that it did not work for you. I found it strange that it wasn’t working for some people and decided to investigate further. I did find some dark themes where this workaround does not work.
When I first tried, it would work perfectly with the few dark themes that I had. I never thought to try any others. I did find some where OpenOffice.org would still appear in high-contrast mode regardless if I had this workaround in place or not. I haven’t been able to find an explanation as to why. I’ll keep investigating the reasons because it doesn’t make sense to me why it isn’t working all of the time.
If anyone comes across a dark theme where this workaround doesn’t change OpenOffice.org to display correctly, please let me know what it is and where I might be able to find it.
October 14th, 2008 at 9:41 pm
Thanks for your response and mainly for your effort trying to make our desktops look better.
Well, sorry for didn’t give you all the details in my last post. I’m using the Overglossed 0.4 theme found in http://www.gnome-look.org/content/show.php/Overglossed?content=74813 which is the same as yours, because that I tried you workaround.
With your workaround and with the Overglossed theme OO.o 2.4.1 applications don’t show icons (only text instead) in the toolbar, but keep the colors of the Overglossed theme. With your workaround, also there’s no icons and the theme is a dark theme which I’m sure is not Overglossed.
Today I’ve installed OO.o 3.0 and by default the applications show high contrast icons and the colors of Overglossed theme… I’m gonna try your workaround with this new version and post the results.
I hope this information can help and if there’s some way I can help…
please let me know…
October 17th, 2008 at 7:27 pm
Thanks!
this worked exactly like what i had wanted!
i wonder if you have time to adapt this workaround for gedit or a generic guide which could work for any software.
could you write a script to do these automatically when run as root?
it would be easier for newbies who want to use a dark theme.
thanks again for this useful post!
October 25th, 2008 at 9:33 pm
I’m using the Overglossed dark theme and had the same issues. So I tried your workaround and ended up not having OOo start at all! I’m quite the linux n00b. I’m using hardy and love it! I know, at this point, just enough to be dangerous!
Can you give me some clear tips to be able to get the OOo suite up and running?
Thanks…
October 26th, 2008 at 1:52 am
The only time I had an issue with OO.o not running during this workaround was that it couldn’t find the binary file because it was looking for it with the wrong name. That was why I had to either rename the binary file or change the line in the script that called it. This is covered under step 5. You need to do either 5a or 5b, but not both. 5a just renames the binary file whereas 5b forces the script to call it by its original name. If you did both or neither, then the OO.o scripts would be looking for a file that doesn’t exist.
You can double check to see if this is the case by trying to run an OO.o app from inside a terminal window at the command line. If you use oowriter to launch OO.o Word Processor from the command line, it would launch as if you clicked on its Main Menu listing but with errors and warnings being outputted to the terminal window. When it fails to launch, you should see why in the terminal window.
For instance, if I followed steps 1-4 and didn’t rename the soffice.bin file, I get a /usr/lib/openoffice/program/soffice1: 364: /usr/lib/openoffice/program/soffce1.bin: not found error. Following either step 5a or 5b fixes this.
If I did both steps 5a and 5b, I get an ERROR 4 forking process error.
If I didn’t chmod the new soffice1 script correctly as in step 3, I get an env: /usr/lib/openoffice/program/soffice1: Permission denied error.
The best thing to do is retrace your steps and see where you may have made an error. If you luck out, you’ll find it and correct it on your own.
November 30th, 2008 at 12:32 pm
Thanks nice work.
December 4th, 2008 at 12:30 pm
I find adding the line:
GTK2_RC_FILES=you_fav_theme_gtk_file
export GTK2_RC_FILES
near the beginning of /ooopath/soffice, did the same trick.
Just have to remember to remove it once (if ever) this bug is fixed.
December 21st, 2008 at 6:24 am
Hey, I made a script to automate this :D
http://aur.archlinux.org/packages/openoffice-dark-gtk-fix/openoffice-dark-gtk-fix/openoffice-dark-gtk-fix.sh
BEFORE YOU RUN IT. You will have to change a line in there at the top, where it says OpenOffice installation directory, make sure it says
OOO_INSTALLATION_DIR=/usr/lib/openoffice/program/ (with the trailing slash too) for Ubuntu. This script was set up for Arch, but changing the installation directory to wherever it’s installed will make it work on any distro :) Also this makes it work with gtk-qt-engine.
RZ.com Disclaimer: As is stated in the script’s code, USE AT OWN RISK!
January 3rd, 2009 at 12:03 pm
Lol! Is even easyer:
right click in main menu—> edit menus
Search the icons in the menu
add to the comand:
env GTK2_RC_FILES=/usr/share/themes/Human/gtk-2.0/gtkrc
so it ends like:
env GTK2_RC_FILES=/usr/share/themes/Human/gtk-2.0/gtkrc openoffice.org3 -writer %U
for example…
you may also like to have a launcher like this:
env GTK2_RC_FILES=/usr/share/themes/Human/gtk-2.0/gtkrc soffice
Dont know why but that worked preety well, even if i open directly any file
January 10th, 2009 at 5:24 pm
I am using ubuntu 8.04.1
I changed to OpenOffice 3.0.
It WAS wirking fine (with the Fix…….
“sudo mv /usr/lib/openoffice/program -t /opt/openoffice.org3/program”
My ubuntu was up-dated to version 2.6.24-23.
Now I’m Having problems…. Menu vanished,Dark screen, Freze maybe more!
Will your FIX work for OpenOffice 3.0??
January 10th, 2009 at 11:12 pm
Sorry!! You have ALREADY answered my question
I’ve read your instructions again, Thanks.
I am completely NEW to ubuntu GNU/Linux.
Your earlier Post was easy to follow.
This seems a bit mor ‘Teck-Geek’, I hope I can do it.
“THE FOOLS GUIDE” is what I need.
I’ll be back with my thanks in a week or so.
I appreciate your help and the excellent posts.
Jack
January 22nd, 2009 at 10:35 am
Just tried this with openoffice 3 and ubuntu ibex. I adjusted the file paths accordingly and it works an absolute treat. Nice tutorial.
January 29th, 2009 at 3:04 pm
Hi, I’ve just followed your instructions and everything’s fine, thank you very much!
But I seem to have the same problem using gFTP, do you have any idea how to fix it?
January 30th, 2009 at 9:39 pm
Tralala,
For something like gFTP, I’d follow the example that Stratok explained a few comments up. Edit the menu listing and prepend the launch command with
env GTK2_RC_FILES=/usr/share/themes/Human/gtk-2.0/gtkrc
January 31st, 2009 at 5:09 pm
Yep, I should’ve red all the comments before.
Everything seems to be fixed, thank both of you, Adam and Stratok :)
February 7th, 2009 at 5:12 pm
Thanks a lot Stratok! Your fix is exactly what I was looking for.
March 14th, 2009 at 12:26 am
Thank you for this. Worked great.