Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'a possible script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
a possible script
Authored by: SOX on Jan 06, '04 10:42:54AM
Use the following script (or make a terminal icon out of it) to switch users by saving this as "fus", make it executable , and type: fus

#!/bin/sh
renice 20 -u $USER 
if [[ -z $1 ]]; then
  # robg note: Please enter the next two lines as one without
  # any spaces between "
  /System/Library/CoreServices/Menu\ Extras/user.menu/Contents/Resources/CGSessi
on -suspend
else
  userID=`id -u $1`;
  if [[ -z $userID ]]; then
    exit -1;
  fi;
  # robg note: Please enter the next two lines as one without
  # any spaces "
  /System/Library/CoreServices/Menu\ Extras/user.menu/Contents/Resources/CGSessi
on -switchTouserID $userID
fi;
I'm not quite sure where to put the hook to renice the new user back to 10. But the new user could type

renice 10 -u $USER
to restore his/her own priority

[ Reply to This | # ]
slight problem...
Authored by: MattHaffner on Jan 06, '04 11:36:47AM
The hitch with renice-ing is that the user can't restore their processes to the proper level without sudo privileges. You are only allowed to increase your own process nice level, not decrease it.

If you allow all your users to have sudo then it's not an issue, and you could hook a "renice 10 -u $userID" in before the -switchTouserID line. The script will always have to be run 'sudo', of course.

[ Reply to This | # ]

slight problem...
Authored by: SOX on Jan 06, '04 05:00:54PM

Maybe one could just make this a setUID executable with the owner as root and executable by all. If that were done then you could also use the root priviledge to set the nice level of the incoming user to 0 or 10 or something good in the same script.
that is add:

renice 10 -u $1
to the end.



[ Reply to This | # ]