Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
azzaOffline
Post subject: GUI login not recognised by system  PostPosted: 21.02.2011, 08:12



Joined: 2010-09-15
Posts: 11

Status: Offline
I did not know I had a problem until I recently tweaked mythtv to shutdown the system when it had nothing to do.
Before shutting down, mythtv runs a script to check that nobody is logged in. You can choose any one of many commands to get the system to check for logged users. The mythtv wiki recommends 'w', but others have used 'who' or 'last'.

My problem is that when I am logged into my kde desktop, the system does not count me as logged in unless I open a terminal. Even a graphical terminal like konsole will do.

For example, if I open a konsole window and run 'w', I get:
      Code:
$ w
 17:53:25 up 6 min,  1 user,  load average: 0.05, 0.23, 0.15
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
aaron    pts/0    :0.0             17:53    0.00s  0.17s  0.01s w

Notice that at 17:53, the system had been up for 6mins, but that the only user logged in at 17:53! That's when I opened konsole.

I made a little script to run the 'w' command so that I could do it without a termianl open. The result is:
      Code:
17:53:10 up 6 min,  0 users,  load average: 0.06, 0.24, 0.15
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT

This was run just before I opened the konsole used in my first example.

Interestingly, each time I open a terminal (konsole window) the system shows another user logged in. This is the output of 'w' run from the 2nd of 2 open konsole windows:
      Code:
$ w
 17:54:07 up 7 min,  2 users,  load average: 0.02, 0.20, 0.14
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
aaron    pts/0    :0.0             17:53   42.00s  0.16s  0.16s /bin/bash
aaron    pts/1    :0.0             17:54    0.00s  0.15s  0.00s w


To make sure I can continue using my desktop without mythtv shutting the system down (because the system is showing no logged-in users), I just make sure I always have a konsole open, but wish I did not have to do this.

How can I make sure the system actually recognises and logs my graphical login??
 
 View user's profile Send private message  
Reply with quote Back to top
michaaa62Offline
Post subject: RE: GUI login not recognised by system  PostPosted: 21.02.2011, 08:20



Joined: 2010-09-11
Posts: 53
Location: Berlin, Germany
Status: Offline
No solution, may be a workaround: Just autostart yakuake. Runs in the background, easy to access when needed
 
 View user's profile Send private message  
Reply with quote Back to top
muchan
Post subject: RE: GUI login not recognised by system  PostPosted: 21.02.2011, 08:45
Moderator


Joined: 2010-09-11
Posts: 468

What about disabling the script to shutdown, if it does what you don't want?
 
 View user's profile Send private message  
Reply with quote Back to top
azzaOffline
Post subject: Re: RE: GUI login not recognised by system  PostPosted: 21.02.2011, 08:58



Joined: 2010-09-15
Posts: 11

Status: Offline
      muchan wrote:
What about disabling the script to shutdown, if it does what you don't want?

But it does do what I want...
When I am finished working I log out. When mythtv has nothing to record, then the system will shutdown.
It also wakes the system when recordings are scheduled. The script then allows the system to shutdown when this work is done.

Does everyone else with aptosid have a similar output to 'w' as I do?
 
 View user's profile Send private message  
Reply with quote Back to top
azzaOffline
Post subject: Re: RE: GUI login not recognised by system  PostPosted: 21.02.2011, 09:08



Joined: 2010-09-15
Posts: 11

Status: Offline
      michaaa62 wrote:
No solution, may be a workaround: Just autostart yakuake. Runs in the background, easy to access when needed
Great idea. I'd never heard of yakuake until now, but it is a very useful little app' and doesn't use many system resources, so I'll use this idea as my workaround until a real solution is found.
Thanks.
 
 View user's profile Send private message  
Reply with quote Back to top
cid-babaOffline
15 Post subject: RE: Re: RE: GUI login not recognised by system  PostPosted: 21.02.2011, 12:20



Joined: 2010-09-11
Posts: 24

Status: Offline
I have got a problem with w, too. (got the same config with mythtv) My Problem is: w doesn't count log-offs from KDE. The system will only shut down, if i wasn't logged into KDE. Logins to console are no problem... (to be exact: only the usercounter in the first row shows wrong things, the list underneath is correct)

Since I'm the only user of the Pc I wrote a workaround in the mythtv-checklogin-script. Now it searches for my username or root in the output of w - that works, but I don't like this solution.

I hadn't heard of "who" and "last" before - maybe the best solution is to throw buggy w away and use one of the alternatives? Maybe I'll find some time later to try these...

EDIT:

hello everybody - I've got a solution that works without problems, at least on my PC:
      Code:
# Check to see if anyone is currently logged in. Return zero if not and 1 if so.
# Echoed text appears in /var/log/mythtv/mythbackend.log
if
  who -q | grep -q "=0"
  then
    #echo Nobody logged in!
    exit 0
  else
    #echo Somebody logged in!
    exit 1
fi


As I'm not a pro with script-programming I'd be glad for hints Wink e.g. should there be a #!/bin/bash at the beginning?
 
 View user's profile Send private message  
Reply with quote Back to top
azzaOffline
Post subject: Re: RE: Re: RE: GUI login not recognised by system  PostPosted: 21.02.2011, 21:23



Joined: 2010-09-15
Posts: 11

Status: Offline
      cid-baba wrote:
As I'm not a pro with script-programming I'd be glad for hints Wink e.g. should there be a #!/bin/bash at the beginning?


Well you're better than me, I know NOTHING about writing scripts (although I do always see/use the #!/bin/bash line at the beginning). I have however seen one other example of a script using 'who' which is very similar to yours. Here it is FYI:
      Code:
who -q | grep -q 'users=0'
if [ "$?" == "1" ]
then
    echo "Shutdown check failed: users still logged in."
    exit 1
fi

Unfortunately for me, that script, and yours also, refer to the count of users which for me is often 0, even with 'who'.


Perhaps I should just continue with my workaround. If your experience is that a logout from KDE is not noticed, then I am perhaps lucky that my login to KDE was also not noticed!

I also sometimes have problems with the user count as well though, so could you please post your 'w' script here as that modification could really help me and I don't know how to have more than one choice in the script (i.e. 1 for each user). At the moment my script is a simply 'if' 0 users, 'else'...
 
 View user's profile Send private message  
Reply with quote Back to top
cid-babaOffline
Post subject: Old Script  PostPosted: 21.02.2011, 22:24



Joined: 2010-09-11
Posts: 24

Status: Offline
This is my old workaround-script - if you need more users add more "if"s Wink

      Code:
if
  ! w | grep -q "yourusername"
  then
    echo User is not logged in!
    if
      ! w | grep -q "root"
      then
   echo root is not logged in either, shut down!
        #more ifs here, if you need them...
   exit 0
      else
   echo root logged in. Wait!
   exit 1
    fi
  else
    #echo User logged in. Wait!
    exit 1
fi


But I don't think that it will help you much - the output of w ist terribly wrong on your pc... It seems that there is a bigger problem (not with w - if the output of who shows the same problems - but with the thing behind it) that should be solved, otherwise you might get other additional problems Wink Maybe anyone else can help?
 
 View user's profile Send private message  
Reply with quote Back to top
azzaOffline
Post subject:   PostPosted: 21.02.2011, 22:45



Joined: 2010-09-15
Posts: 11

Status: Offline
thanks
 
 View user's profile Send private message  
Reply with quote Back to top
cid-babaOffline
Post subject:   PostPosted: 25.06.2011, 12:51



Joined: 2010-09-11
Posts: 24

Status: Offline
Don't know if anyone is still interested - but I've found a solution! The problem is KDM! I've installed Gnome 3 from experimental to test it. But I noticed that KDM didn't count logins to Gnome (or any other WM except of KDE). GDM3 counts every login, so switching to GDM3 is a solution. (don't forget to change runlevels, explained here: http://manual.aptosid.com/en/wm-dm-en.htm)
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 12 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by Zafenio