Refracta Development, Scripts, etc.
Post a reply
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## change-username script needs to know display manager

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:
  `# 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
  `

dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: change-username script needs to know display manager

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)
thwak

- thwak
- Posts: 174
- Joined: Tue Nov 20, 2012 3:58 am

## Re: change-username script needs to know display manager

Fri Oct 18, 2013 9:03 am

could test

Code:
  `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
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: change-username script needs to know display manager

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:
  `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:
  `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
raymerjacque

- raymerjacque
- Posts: 111
- Joined: Sun Nov 03, 2013 9:37 am

## Re: change-username script needs to know display manager

Sun Nov 03, 2013 10:36 am

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

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: change-username script needs to know display manager

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.
raymerjacque

- raymerjacque
- Posts: 111
- Joined: Sun Nov 03, 2013 9:37 am

## Re: change-username script needs to know display manager

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
dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: change-username script needs to know display manager

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:
  `#!/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`

fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: change-username script needs to know display manager

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:
  `ps ax |grep mdm`

Thanks.
@dzz: Thanks, that looks much better.
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: change-username script needs to know display manager

Sun Nov 03, 2013 4:45 pm

Of maybe like this, so that sysv-rc-conf isn't needed. Can you test, please?

Code:
  `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?
Post a reply
Jump to:

Powered by phpBB © phpBB Group.

phpBB Mobile / SEO by Artodia.