Welcome
Welcome to refracta

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!

change-username script needs to know display manager

Refracta Development, Scripts, etc.

change-username script needs to know display manager

Postby fsmithred » Thu Oct 17, 2013 11:58 pm

The standalone change-username script has to kill the xserver. Below is the section that determines what gets killed. I just added slim. Are there any other display managers that need to be added, and does slim show up as slim in ps? Hm... I guess another good question is whether or not something else might show up in ps that has the letters s-l-i-m in the name? That could be a problem.

Code: Select all
# Test if xinit or a display manager is running, and save the information
# for later use.
if ps -C xinit; then
  dm_status="no"
elif
  ps -C gdm; then
  dm_status="yes"
  dm="gdm"
elif
  ps -C gdm3; then
  dm_status="yes"
  dm="gdm3"
elif
  ps -C kdm; then
  dm_status="yes"
  dm="kdm"
elif
  ps -C xdm; then
  dm_status="yes"
  dm="xdm"
elif
  ps -C lightdm; then
  dm_status="yes"
  dm="lightdm"
elif
  ps -C slim; then
  dm_status="yes"
  dm="slim"
fi
User avatar
fsmithred
 
Posts: 1987
Joined: Wed Mar 09, 2011 9:13 pm

Re: change-username script needs to know display manager

Postby dzz » Fri Oct 18, 2013 2:00 am

Are there any other display managers that need to be added


Depends if you want to support the Trinity (kde3 fork) DM, "tdm" .. It's used here.

Unfortunately using ps -C this only works for the "testing" (but due for release quite soon) version R14

The current 3.5.13-2 release can only be detected as "kdm" using ps -C because the actual process is /opt/trinity/bin/kdm (not tdm till R14)
dzz
 
Posts: 629
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: change-username script needs to know display manager

Postby thwak » Fri Oct 18, 2013 9:03 am

could test
Code: Select all
xset -q

but that wouldn't provide a name
nor does
NAME
pidof -- find the process ID of a running program.
SYNOPSIS
pidof -s -x -o omitpid -o omitpid.. program program..
DESCRIPTION
Pidof finds the process id's (pids) of the named programs. It prints those id's on the standard output.

...so what you've already coded seems best
thwak
 
Posts: 165
Joined: Tue Nov 20, 2012 3:58 am

Re: change-username script needs to know display manager

Postby fsmithred » Fri Oct 18, 2013 10:00 am

I don't remember where I found it, but this is in my notes. (gedit is just an example)
Code: Select all
ps ax | grep gedit  NO!

ps -C gedit
pgrep gedit
ps -C gedit -opid=    # show the pid for the given command
ps -p <pid> -ocmd=    # show the command for the given pid
pidof gedit (obsolete)


Code: Select all
xset -q
Hm... That says DPMS is off, yet my xorg.conf has Option "DPMS" in it. Now I'm getting way off topic. Gonna look into this some more - my monitors don't go as black as I'd like when I leave the computer for a long time.

Note to self: https://wiki.archlinux.org/index.php/Di ... _Signaling
User avatar
fsmithred
 
Posts: 1987
Joined: Wed Mar 09, 2011 9:13 pm

Re: change-username script needs to know display manager

Postby raymerjacque » Sun Nov 03, 2013 10:36 am

i dont see "mdm" in that list? I know we use MDM for makululinux
raymerjacque
 
Posts: 105
Joined: Sun Nov 03, 2013 9:37 am

Re: change-username script needs to know display manager

Postby fsmithred » Sun Nov 03, 2013 12:50 pm

raymerjacque wrote:i dont see "mdm" in that list? I know we use MDM for makululinux


Does it run as "mdm" or does it run as "mdm-<something>"? Running 'apt-file find mdm' shows mdm-run, mdm-sync and mdm.screen in /usr/bin/.

I also came across mention of awesome window manager. Guess I need to add that, too, and I have the same question about it - what name does it use when running. Killing everything with 'adm' in its name is starting to get scary. I can imagine a process with 'admin' in the name getting killed by mistake. I might need to beef up the tests a bit or get some user interaction in there.
User avatar
fsmithred
 
Posts: 1987
Joined: Wed Mar 09, 2011 9:13 pm

Re: change-username script needs to know display manager

Postby raymerjacque » Sun Nov 03, 2013 1:50 pm

there is quite a few mdm entries, not sure which you are looking for. here is a screenshot

http://s24.postimg.org/5sksr0enp/display_manager.png
raymerjacque
 
Posts: 105
Joined: Sun Nov 03, 2013 9:37 am

Re: change-username script needs to know display manager

Postby dzz » Sun Nov 03, 2013 2:29 pm

This change to the original test code correctly detects (here, in wheezy and sid) Trinity DM, both current "release" and "testing" versions:

Code: Select all
#!/bin/bash

# Test if xinit or a display manager is running, and save the information
# for later use.
if ps -C xinit ; then
  dm_status="no"
elif
  ps -C gdm ; then
  dm_status="yes"
  dm="gdm"
elif
  ps -C gdm3 ; then
  dm_status="yes"
  dm="gdm3"

## changed: ##

elif
  ps -C kdm ; then
  dm_status="yes"
   # Trinity DM (3.5.13 versions) actual PID shows as "kdm"
   if /usr/sbin/sysv-rc-conf  --list kdm-trinity|grep ":on" ; then
   dm="kdm-trinity"
   else
     dm="kdm"
   fi

## added: ###

elif
  # Trinity DM (R14 "testing" versions)
  ps -C tdm ; then
  dm_status="yes"
  dm="tdm-trinity"

###############################

elif
  ps -C xdm ; then
  dm_status="yes"
  dm="xdm"
elif
  ps -C lightdm ; then
  dm_status="yes"
  dm="lightdm"
elif
  ps -C slim ; then
  dm_status="yes"
  dm="slim"
fi

echo "$dm is detected"

# shutdown detected DM
# service $dm stop
dzz
 
Posts: 629
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: change-username script needs to know display manager

Postby fsmithred » Sun Nov 03, 2013 4:34 pm

@raymerjacque: Could you post the ouput of this command for me, please? That way, I can see what processes are actually running when you're on the desktop.
Code: Select all
ps ax |grep mdm
Thanks.

@dzz: Thanks, that looks much better.
User avatar
fsmithred
 
Posts: 1987
Joined: Wed Mar 09, 2011 9:13 pm

Re: change-username script needs to know display manager

Postby fsmithred » Sun Nov 03, 2013 4:45 pm

Of maybe like this, so that sysv-rc-conf isn't needed. Can you test, please?
Code: Select all
elif
  ps -C kdm ; then
  dm_status="yes"
   if ps -C kdm-trinity; then
      dm="kdm-trinity"
    else
      dm="kdm"
    fi
elif


And just to make sure I understand correctly - there's no plain "tdm" in the ps output, just tdm-trinity?
User avatar
fsmithred
 
Posts: 1987
Joined: Wed Mar 09, 2011 9:13 pm

Next

Return to Discuss

Who is online

Users browsing this forum: No registered users and 0 guests

suspicion-preferred