SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-05-20 12:10:56

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

[SOLVED] x11vnc status and conky entry question(s)

Note for anyone else looking for similar answers: be sure to read the entire thing, there was quite a bit of trial & error involved.

I never did like VNC servers running totally silent, as I tend to forget to shut them off tongue. I only start it when I need to (with the -forever flag). I'd like to know if there's a way to change the obmenu entry that will start it without terminator (i.e not "nohup terminator command=.."). If there is, I'd also like to know what entry I could add for stopping the server.

Lastly, I know conky can display text file output; is there a way to somehow make it poll whether or not x11vnc is running, and if there's anyone connected?

/Savonlinna

Last edited by Savonlinna (2009-05-20 18:08:43)


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

Help fund CrunchBang, donate to the project!

#2 2009-05-20 12:40:21

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

there are two ways you could check that I know of if vnc is running, do a netstat and check the ports, or ps aux | grep [vnc executable.... not susre if it's just vnc]
you could write a simple shell script then call it from conky with execi, something along the lines of this
#!/bin/sh
if ps aux | grep vnc ; then
  echo "vnc running"
else
   echo "vnc not running"
fi


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#3 2009-05-20 13:33:37

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

iggykoopa wrote:

there are two ways you could check that I know of if vnc is running, do a netstat and check the ports, or ps aux | grep [vnc executable.... not susre if it's just vnc]
you could write a simple shell script then call it from conky with execi, something along the lines of this
#!/bin/sh
if ps aux | grep vnc ; then
  echo "vnc running"
else
   echo "vnc not running"
fi

Sweet, that's in the right direction. Is there any way to exclude things? I currently have it doing grep "x11vnc -usepw -forever", but that will also include the obmenu entry as well as the grep command itself. Don't want it saying it's running just because I asked if it was big_smile


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

#4 2009-05-20 13:50:33

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

you could try:
ps aux | grep vnc | grep -v grep
the -v means everything that doesn't match that pattern, I would need to know what the obmenu entry looks like to know how to exclude it. Hope that helps.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#5 2009-05-20 14:03:32

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

iggykoopa wrote:

you could try:
ps aux | grep vnc | grep -v grep
the -v means everything that doesn't match that pattern, I would need to know what the obmenu entry looks like to know how to exclude it. Hope that helps.

The obmenu entry is simply terminator --command="x11vnc -usepw -forever".

Edit:
On a related note; if I do get it to output to conky correctly, can the obmenu entry be edited to have terminator run the (or any, for that matter) command without it staying open? I know nohup will let you close the terminal, but it still has to be closed manually the way I understand it. Sorry if I'm being a bit of a crackhead here, I'm not even entirely sure what to google for in this case : )

Last edited by Savonlinna (2009-05-20 14:08:09)


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

#6 2009-05-20 14:10:28

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

I think this should work then:
ps aux | grep x11vnc | grep -v grep terminator
if that doesn't work try:
ps aux | grep x11vnc | grep -v grep | grep -v terminator
also for the connected clients try:
x11vnc -query clients

I'm not sure on the terminator thing...you could try changing the obmenu entry to just "x11vnc -usepw -forever" without the terminator part and see if it still runs.

Last edited by iggykoopa (2009-05-20 14:12:05)


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#7 2009-05-20 15:18:20

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

ps aux | grep x11vnc | grep -v grep | grep -v terminator works fine when it's not running. It still outputs when it is running, though

robin     9946  0.0  0.5  23908  7828 ?        S    17:06   0:00 x11vnc -usepw -forever

Obviously the process itself. Getting very close now!  And your obmenu solution was flawless btw!


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

#8 2009-05-20 15:37:36

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

yup if you change that line in the script it should output correctly now i.e.

#!/bin/sh
if ps aux | grep x11vnc | grep -v grep | grep -v terminator ; then
  echo "vnc running"
else
   echo "vnc not running"
fi

save that to a file then chmod +x whatever.sh . Then call it from conky, ${execi 1 /path/to/whatever.sh} and you should be good. If you removed the terminator part from the menu you should be able to remove the grep -v terminator part as well. Also you could modify the shell script to make a pipemenu that shows "start vnc" when it is stopped and "stop vnc" when it is running. Did the x11vnc -query clients command work? If it did you can call it from conky also.

Last edited by iggykoopa (2009-05-20 15:39:07)


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#9 2009-05-20 16:12:07

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

ps aux | grep x11vnc | grep -v grep didn't change it. Still shows the process. Pipe menu's a good idea, I'll have to look in to that.
-query clients doesn't want to play nice, but -query client_count does big_smile It also adds some stuff I'd want to have omitted though, I just want the number:

x11vnc -query client_count

>>> sending remote command: "qry=client_count" via X11VNC_REMOTE X property.
aro=client_count:1

"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

#10 2009-05-20 16:21:35

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

try:
x11vnc -query client_count | grep aro | sed 's/aro=client_count://'


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#11 2009-05-20 16:24:09

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

now it's down to
>>> sending remote command: "qry=client_count" via X11VNC_REMOTE X property.
1


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

#12 2009-05-20 16:37:27

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

ok tested out the script on my machine and it was doing the same thing....try this:
#!/bin/sh

running=`ps aux | grep x11vnc | grep -v grep | grep -v terminator`
if [ -n "$running" ] ; then
  echo "vnc running"
else
   echo "vnc not running"
fi


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#13 2009-05-20 16:44:22

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

and for the other command try this:
x11vnc -query client_count 2> /dev/null | sed 's/aro=client_count://'


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#14 2009-05-20 16:58:10

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

script master indeed smile thanks alot for all the help!
one last thing (sorry, man wink)

${alignr}${execi 1.2 ~/./scripts/vncc.sh} works fine
${alignr}${execi 1.2 ~/./scripts/cvnc.sh} does not. any idea why?

Edit:
vncc being active/inactive check and cvnc the client count

Last edited by Savonlinna (2009-05-20 17:06:27)


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

#15 2009-05-20 17:07:54

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

did you chmod +x cvnc.sh?


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#16 2009-05-20 17:12:58

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

yup


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

#17 2009-05-20 17:17:04

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

and cvnc.sh looks like this?

#!/bin/sh

x11vnc -query client_count 2> /dev/null | sed 's/aro=client_count://'

other than that I'm not sure what could be wrong...maybe try absolute paths instead of ~
glad it's working other than that for you though, I like working on stuff like this.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#18 2009-05-20 17:31:18

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

to the letter.
thought so too, but it didn't help. but i'm pretty sure i'll survive it not working smile

Edit:
thought i'd at least have the count run in terminator, with a pause when it's done;
terminator --command="x11vnc -query client_count & read -p 'Press any key when done'" works. sort of. know of a remedy for the awkward read message?

>>> sending remote command: "qry=client_count" via X11VNC_REMOTE X property.
Press any key when donearo=client_count:0

Last edited by Savonlinna (2009-05-20 17:41:27)


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

#19 2009-05-20 17:51:26

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

terminator --command='x11vnc -query client_count 2> /dev/null & echo "Press any key when done" & read'


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#20 2009-05-20 18:01:59

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

resolved. again, thanks for the help!

gotta ask though, /dev/null is the "black hole" of unwanted output/errors, right? and 0, 1, 2 are in, out, error respectively unless i'm mistaken. so, is that simply telling it that any output below 2 from the command preceding it, will be /dev/null'd?


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

#21 2009-05-20 18:04:40

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: [SOLVED] x11vnc status and conky entry question(s)

I'm just having it send the
>>> sending remote command: "qry=client_count" via X11VNC_REMOTE X property.
line to /dev/null. Don't know why it runs that way(having that as error output) But yeah you have the right idea.

edit: just reread your post 2> makes it discard any errors...not anything less than two, think of the > as redirecting it, you could say 2> somefile.txt and it would write the errors to somefile.txt

Last edited by iggykoopa (2009-05-20 18:07:23)


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#22 2009-05-20 18:06:30

Savonlinna
Member
From: Sweden
Registered: 2009-05-19
Posts: 35

Re: [SOLVED] x11vnc status and conky entry question(s)

i'll have to read up on it then. seems like it could be real useful.
thanks again, marking thread solved!


"History is the fiction we invent to persuade ourselves that events are knowable and that life has order and direction."

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo