Page 1 of 1

Mint fortunes in terminal

Posted: Wed May 04, 2011 1:51 pm
by willie42
I have been trying to find a way to fix mine but for some reason I am getting different error messages than others that I have seen on other post. If someone could shine a little light on it or point me in the right direction help is much appreciated

Code: Select all

/usr/bin/mint-fortune: line 35: unexpected EOF while looking for matching `"'
/usr/bin/mint-fortune: line 44: syntax error: unexpected end of file


thats the error message I am getting

thanks :D

Re: Mint fortunes in terminal

Posted: Thu May 05, 2011 11:05 am
by twa
willie42,
is this what R U looking for?
http://forums.linuxmint.com/viewtopic.php?f=42&t=845
:?:

Re: Mint fortunes in terminal

Posted: Thu May 05, 2011 11:10 am
by willie42
Not exactly. That is for removing the fortune. I want them to work again. I am getting something different than what the standard fix is. Thanks. I am starting nights tonight but will start looking for fixes.

thanks
Willie42 :D

Re: Mint fortunes in terminal

Posted: Thu May 05, 2011 1:57 pm
by twa

Re: Mint fortunes in terminal

Posted: Thu May 05, 2011 2:20 pm
by willie42
I looked at this one but I am getting different errors. This part of my script is ok the error of the post that you showed me is

/usr/bin/mint-fortune: line 35: [: ==: unary operator expected

Mine is

/usr/bin/mint-fortune: line 35: unexpected EOF while looking for matching `"'
/usr/bin/mint-fortune: line 44: syntax error: unexpected end of file

I have 2 lines that have issues and I don't yet know whats going on with them. I have to work tonight 7 pm to 7 am I will most likely look at it again in the morning and then see if I can figure out how I can fix it.

Code: Select all

# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

use_color=false

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.  Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs}    ]] \
        && type -P dircolors >/dev/null \
        && match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
        # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
        if type -P dircolors >/dev/null ; then
                if [[ -f ~/.dir_colors ]] ; then
                        eval $(dircolors -b ~/.dir_colors)
                elif [[ -f /etc/DIR_COLORS ]] ; then
                        eval $(dircolors -b /etc/DIR_COLORS)
                fi
        fi

        if [[ ${EUID} == 0 ]] ; then
                PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
        else
                PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
        fi

        alias ls='ls --color=auto'
        alias grep='grep --colour=auto'
else
        if [[ ${EUID} == 0 ]] ; then
                # show root@ when we don't have colors
                PS1='\u@\h \W \$ '
        else
                PS1='\u@\h \w \$ '
        fi
fi

# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs

# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
#    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
#    ;;
#*)
#    ;;
#esac

# enable bash completion in interactive shells
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found ]; then
	function command_not_found_handle {
	        # check because c-n-f could've been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
		   /usr/bin/python /usr/lib/command-not-found -- $1
                   return $?
		else
		   return 127
		fi
	}
fi

/usr/bin/mint-fortune

if [ "$PS1" ] ; then  
   mkdir -p -m 0700 /dev/cgroup/cpu/user/$$ > /dev/null 2>&1
   echo $$ > /dev/cgroup/cpu/user/$$/tasks
   echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi

here is what my bash.bashrc file looks like. If you want to see if you see something let me know

Re: Mint fortunes in terminal

Posted: Fri May 06, 2011 2:15 am
by twa
willie42,
gksu gedit /etc/bash.bashcr from fresh install, U can try to replace your with this:
# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

use_color=false

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS. Try to use the external file
# first to take advantage of user additions. Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] \
&& type -P dircolors >/dev/null \
&& match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if type -P dircolors >/dev/null ; then
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
fi

if [[ ${EUID} == 0 ]] ; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi

alias ls='ls --color=auto'
alias grep='grep --colour=auto'
else
if [[ ${EUID} == 0 ]] ; then
# show root@ when we don't have colors
PS1='\u@\h \W \$ '
else
PS1='\u@\h \w \$ '
fi
fi

# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs

# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
# ;;
#*)
# ;;
#esac

# enable bash completion in interactive shells
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found ]; then
function command_not_found_handle {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/bin/python /usr/lib/command-not-found -- $1
return $?
else
return 127
fi
}
fi

/usr/bin/mint-fortune

if [ "$PS1" ] ; then
mkdir -p -m 0700 /dev/cgroup/cpu/user/$$ > /dev/null 2>&1
echo $$ > /dev/cgroup/cpu/user/$$/tasks
echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi
:roll:

Re: Mint fortunes in terminal

Posted: Fri May 06, 2011 8:20 am
by willie42
I thought about that as a last resort but I am thinking that is what I will have to do. I was hoping to just replace the 2 lines. I just got home from work and I have to be back tonight. So what I will do if I wake up in time I will load live USB on my other pc and let it boot to it then copy it over. thanks for you help TWA. I really appreciate it very much.

:mrgreen: :D

Re: Mint fortunes in terminal

Posted: Sat May 07, 2011 9:55 am
by ChromeMukuro
i tried copying the given replacement bash.bashrc, but i am still reciving the following error:

Code: Select all

/usr/bin/mint-fortune: line 35: [: ==: unary operator expected
bash: /dev/cgroup/cpu/user/3743/tasks: No such file or directory
bash: /dev/cgroup/cpu/user/3743/notify_on_release: No such file or directory
sorta annoying.... i miss the fortunes...

Re: Mint fortunes in terminal

Posted: Sat May 07, 2011 3:09 pm
by twa

Re: Mint fortunes in terminal

Posted: Sun May 08, 2011 1:26 pm
by ChromeMukuro
no when i open a terminal i still get:

Code: Select all

bash: /dev/cgroup/cpu/user/9797/tasks: No such file or directory
bash: /dev/cgroup/cpu/user/9797/notify_on_release: No such file or directory

Re: Mint fortunes in terminal

Posted: Sun Jun 05, 2011 7:13 pm
by hunkirdowne
I had this and fixed it.

http://community.linuxmint.com/tutorial/view/447
Some users might be surprised that after doing an update on their LMDE, and opening a Terminal would display an error instead of the lovely cow with random quotes.
/usr/bin/mint-fortune: line 35: [: ==: unary operator expected
To solve this issue, open a Terminal and issue the command below:

Code: Select all

gksudo gedit /usr/bin/mint-fortune
Locate and replace:
if [ $showfortunes == "true" ]; then
with
if [ "$showfortunes"=="true" ]; then
Make sure that there is no spaces in between "$showfortunes"=="true"
Save the file and open a Terminal to test.
Note that my line now reads:
if [ $showfortunes=="true" ]; then
...with no quotes around $showfortunes so the quotes around $showfortunes in the above may just be superfluous.

HTH-HD.

Re: Mint fortunes in terminal

Posted: Mon Jun 06, 2011 6:40 pm
by karashata
I noticed this after an update to mint-fortune as well, and I figured out why it happens: The version of mint-fortune being shipped was updated to work with the "Show fortune cookies" option under Terminal in Desktop Settings in Linux Mint 11 'Katya'. Since the configuration key and the Desktop Settings pane for this option doesn't exist by default in LMDE (I believe the package responsible for this isn't updated in LMDE), it causes mint-fortune to display that error.

How I fixed it was to set the key and its value manually in the terminal.

From the terminal:

Code: Select all

gconftool-2 --set --type=bool /desktop/linuxmint/terminal/show_fortunes true
You could also create the key and set its value in gconf-editor:

1. Select the desktop folder, right-click in the right-hand pane and select "New Key..." from the menu.
2. In the Name textbox, enter "linuxmint/terminal/show_fortunes" (without the quotes), change the type to Boolean, and change the value to True.

Either of these methods should get mint-fortune working correctly, and the value can be set to false by either method if you wish to disable the fortunes until the Desktop Settings applet is updated with the Terminal section and the "Show fortune cookies" option as it is in Mint 11.

Re: Mint fortunes in terminal

Posted: Thu Jun 16, 2011 10:57 pm
by hunkirdowne
karashata wrote:From the terminal:

Code: Select all

gconftool-2 --set --type=bool /desktop/linuxmint/terminal/show_fortunes true
You could also create the key and set its value in gconf-editor:

1. Select the desktop folder, right-click in the right-hand pane and select "New Key..." from the menu.
The above probably works for Linux Mint/Gnome, but not LMDE or KDE as these are Ubuntu-derivative and Gnome-specific instructions. I see a .gconf folder and /desktop below that, but no 'linuxmint'. Also I see no "New Key" option as stated above but this may come with a later release.

I must say that I am moderately pleased with LMDE but more used to the KDE interface and do not much care for Ubuntu's treatment of KDE and Debian proper even seems a little sluggish but v4.6 hasn't made it's way down into stable yet but it has to sid and quite a bit better than it's 4.x predecessors.

All that said, if you like Gnome, you really ought to consider giving LMDE a go as I think you might be quite pleased.

Re: Mint fortunes in terminal

Posted: Fri Jun 17, 2011 5:54 pm
by karashata
hunkirdowne wrote:
karashata wrote:From the terminal:

Code: Select all

gconftool-2 --set --type=bool /desktop/linuxmint/terminal/show_fortunes true
You could also create the key and set its value in gconf-editor:

1. Select the desktop folder, right-click in the right-hand pane and select "New Key..." from the menu.
The above probably works for Linux Mint/Gnome, but not LMDE or KDE as these are Ubuntu-derivative and Gnome-specific instructions. I see a .gconf folder and /desktop below that, but no 'linuxmint'. Also I see no "New Key" option as stated above but this may come with a later release.

...
The instructions might be GNOME-specific, perhaps, since gconf is GNOME's settings backend, however they're not specific to Ubuntu, just GNOME. They should work just fine in LMDE, since those instructions were created from the process I used to add the key to gconf to fix mint-fortune. I'm not sure how you might manage the same in KDE or LXDE (I think that would be what you meant, rather than LMDE as you stated in your comment), but I believe the Mint 11 versions using those environments aren't finished and released yet so the management for enabling or disabling the fortunes in those environments might not be ready yet and probably won't be pushed to LMDE for those environments for a little while later still...

Re: Mint fortunes in terminal

Posted: Sat Jun 18, 2011 1:49 pm
by hunkirdowne
I *think* I know how gconftool would work in this situation but I'm largely unfamiliar with Gnome these days...
karashata wrote: The instructions might be GNOME-specific, perhaps, since gconf is GNOME's settings backend, however they're not specific to Ubuntu, just GNOME. They should work just fine in LMDE, since those instructions were created from the process I used to add the key to gconf to fix mint-fortune. I'm not sure how you might manage the same in KDE or LXDE (I think that would be what you meant, rather than LMDE as you stated in your comment), but I believe the Mint 11 versions using those environments aren't finished and released yet so the management for enabling or disabling the fortunes in those environments might not be ready yet and probably won't be pushed to LMDE for those environments for a little while later still...
My installation of LMDE does not have a '/desktop/linuxmint/terminal/' directory and in fact no 'linuxmint' directory at all in that hiearchy, just '~/.gconf/desktop/gnome'. Again, this might come in a future LMDE release and I do not have a non-Mint Gnome installation to compare to. All this is assuming that gconftool deals with the directories under '~/.gconf/' otherwise I'm totally out of the water on this one.

I could be wrong, but the tutorial instructions I mentioned in an earlier post (http://forums.linuxmint.com/viewtopic.p ... 06#p431506) appear to be generic enough to work within any of the Linux Mint environments so I imagine that KDE and LXDE users would be able to affect the desired change likewise.

LMDE is certainly a work in progress but still a far cry better, IMO, than other distros. My only mild complaint is that KDE isn't an 'out-of-the-box' option but I may circumvent that manually on a faster laptop (I've tried it on an old laptop and things didn't fare quite as well as hoped).

Thanks!

Re: Mint fortunes in terminal

Posted: Sat Jun 18, 2011 2:01 pm
by karashata
Well, I know for a fact that if you just copied or typed the command you quoted from me in a terminal, even though the key doesn't currently exist for you, it would create the key and set it's value to 'true', thereby enabling the fortunes in the terminal without mangling the mint-fortune script. I did it, others did it, and it worked for us, so...

I'm fairly certain the recent batch of Mint related updates for LMDE also should have fixed this by installing a newer version of mintdesktop (the Desktop Settings application) which should be identical to the one shipped with Mint 11 and should have the ability to enable or disable showing the fortunes in terminal windows. That missing gconf key should have been added along with that update.

While I'm sure your instructions do enable the fortunes in the terminal again (and probably work for the other desktop environments), I don't believe it's really a true fix because it disables the ability to conveniently enable or disable the fortunes using Desktop Settings (which as I just stated should have been updated recently to add that ability).

Again, everything I said may only apply to the GNOME-based Mint editions, since I only use GNOME and I'm unsure of how the Mint maintainers plan to approach this issue for the other desktop environments.

Anyway, that's all I really have to say on the matter, I wish I had a little more knowledge and could be a little more helpful, but all I have is my experience to go on, and of course what works for me may not always work for everyone else...