LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-04-2018, 11:24 PM   #1
toolkit
LQ Newbie
 
Registered: Apr 2002
Posts: 26

Rep: Reputation: 15
Simple question on kde kdialog placement


Hi,

I am using a bash script that constantly monitors my server and network. When there
are any issues, it will popup a kdialog with message something like -

/usr/bin/kdialog --display :0 --sorry "va is down" --title "$TIME"

Right now the message is in the centre of the screen. I am thinking of moving the kdialog a bit to my right (so that it can becomes less intrusive). But trying all kinds of settings somehow does not work -

/usr/bin/kdialog --display :0 --sorry "va is down" --title "$TIME" -geometry 50x50+1800+200

I am using Fedora 26. Any help will be appreciated!
 
Old 04-05-2018, 05:24 AM   #2
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 714
Blog Entries: 3

Rep: Reputation: 224Reputation: 224Reputation: 224
kdialog has never worked for me with the --geometry option either.

One method i can think of is to use wmctrl (might have to install the package).

You can do something like this;
Code:
#!/bin/sh

#current time as example
TIME=12:34

# dimensions of kdialog
WIDTH=150
HEIGHT=100
XPOS=1600
YPOS=100

kdialog --display :0 --sorry "va is down" --title $TIME &
sleep 0.5 && wmctrl -r $TIME -e 0,$XPOS,$YPOS,$WIDTH,$HEIGHT
This grabs the window with a title that matches $TIME then resizes/repositions it.
You might have to adjust the sleep value, as wmctrl needs a bit of a delay to wait for the dialog to appear.

Last edited by coralfang; 04-05-2018 at 05:26 AM.
 
Old 04-05-2018, 07:17 AM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
There is also notify-send (from libnotify package) that is less intrusive
Code:
DISPLAY=:0 notify-send "$TIME" "va is down" --icon=dialog-warning
 
Old 04-06-2018, 01:36 AM   #4
toolkit
LQ Newbie
 
Registered: Apr 2002
Posts: 26

Original Poster
Rep: Reputation: 15
Thanks for all tips!

I am currently testing both of the suggestion. I actually monitor quite a few servers
and switches. So the kdialog messages do appear quite frequently, though most of the time there are
false positives.

The wmctrl command does work -

Code:
 ( /usr/bin/kdialog --msgbox "$2 is down" --title "$TIME" & sleep 0.3 && wmctrl -r $TIME -e 0,1700,100,150,100 2> /dev/null ) &
but the shifting of kdialog to the new position is unfortunately distracting.


I was also hoping to incorporate notify-send in another of part of my codes which uses -

Quote:
/usr/bin/kdialog --passivepopup "$2 is down" 10
but discovered Fedora 26 seems to be having issues with it.

The link https://bugzilla.redhat.com/show_bug.cgi?id=1471560
 
Old 04-06-2018, 04:28 AM   #5
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by toolkit View Post

but discovered Fedora 26 seems to be having issues with it.

The link https://bugzilla.redhat.com/show_bug.cgi?id=1471560
Yep it seems to be an upgrade from Fedora 25 to 26 issue, leaving conflict between xfce and kde notification services. Workarounds are posted in the link (starting from the end see comment #31)
 
Old 04-06-2018, 07:37 AM   #6
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 714
Blog Entries: 3

Rep: Reputation: 224Reputation: 224Reputation: 224
Quote:
Originally Posted by toolkit View Post
but the shifting of kdialog to the new position is unfortunately distracting.
I just thought now, you could run the wmctrl command in a loop, for the previous example, modified to look like this:

Code:
#!/bin/sh
TIME="12:34"

# dimensions of kdialog
WIDTH=150
HEIGHT=100
XPOS=1600
YPOS=100


kdialog --sorry "va is down" --title $TIME &

while :
do
	wmctrl -r $TIME -e 0,$XPOS,$YPOS,$WIDTH,$HEIGHT && break
done
This moves the window as instantly as it appears so you don't see it appearing in the default position (also doesn't rely on a "sleep" hack).

Last edited by coralfang; 04-06-2018 at 07:39 AM.
 
Old 04-06-2018, 10:27 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170
Another thing to consider is the Nagios system-monitoring framework, one variety of which is completely open-source. It includes convenient frameworks for building monitoring sensors, and for building displays, and it also includes the requisite "plumbing" in the middle.
 
Old 04-06-2018, 11:52 PM   #8
toolkit
LQ Newbie
 
Registered: Apr 2002
Posts: 26

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by coralfang View Post
This moves the window as instantly as it appears so you don't see it appearing in the default position (also doesn't rely on a "sleep" hack).
You idea works! But I am bit puzzled, why does this method stop it from appearing at the default position? And placing the loop before the kdialog command also does not seem work?


keefaz, I am interested in using notify-send, will digest bug report first.


sundialsvcs, I started this little bash script with very simple requirements (about 10 years),
and then it just grew and grew! That is why I did not consider Nagnois. What I like is this script can
in an instance flash warning when something is not quite right. You literally can feel and understand
the "heartbeat" of the company servers and network. Even with the false positives, I can tell quite
immediately if something really needs quick attention.
 
Old 04-07-2018, 03:35 AM   #9
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 714
Blog Entries: 3

Rep: Reputation: 224Reputation: 224Reputation: 224
Quote:
Originally Posted by toolkit View Post
You idea works! But I am bit puzzled, why does this method stop it from appearing at the default position? And placing the loop before the kdialog command also does not seem work?

Well, the break command will only exit the infinite while loop when wmctrl returns 1. If wmctrl cannot find the window with the title $TIME it will return 0, so the loop continues forever. If you put the loop before the kdialog command, it will simply loop forever as the window will never be created.

By backgrounding the kdialog command (putting a & on the end), the while loop runs immediately. So as soon as kdialog has actually created a window with the title of $TITLE, wmctrl will then move the window faster than it is able to be drawn to the middle of the screen.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Adding a Simple GUI to shell scripts with kdialog LXer Syndicated Linux News 0 11-30-2016 04:11 PM
KDE: simple question mad_alfred Linux - Newbie 5 07-21-2006 09:41 AM
Quick simple KDE question dangerousdave Linux - Newbie 1 03-29-2005 12:33 PM
Simple KDE Question oneman00 Linux - Software 1 12-22-2004 06:45 AM
A simple KDE question tombaaaaa Linux - Newbie 2 08-18-2004 03:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration