You are not logged in.

#1 2018-12-24 15:28:13

rasr11
Member
Registered: 2012-03-26
Posts: 39

Problem in script

I created a shell scripts to re-position termite window (running calcurse) to top right. If I run each line separately in terminal, it works flawlessly. But running it as a shell script does not produce the desired effect. Here is the script :

termite -e calcurse
WID=$(xdotool search --onlyvisible --name 'calcurse')
xdotool windowsize $WID 600 420
xdotool windowmove $WID 1320 0


Can anyone help?

Offline

#2 2018-12-24 15:32:38

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Problem in script

Put in some logging of some sort.  Perhaps check WID after the second command by echoing it to a file.  Do you run those commands exactly like that and in that order from a terminal?  I'd suspect the first one would need to be backgrounded.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-12-24 15:34:21

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 4,645

Re: Problem in script

Moved to Programming and Scripting.


How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.

Offline

#4 2018-12-24 15:39:27

rasr11
Member
Registered: 2012-03-26
Posts: 39

Re: Problem in script

Trilby wrote:

Put in some logging of some sort.  Perhaps check WID after the second command by echoing it to a file.  Do you run those commands exactly like that and in that order from a terminal?  I'd suspect the first one would need to be backgrounded.

I ran these commands exactly as above in the same order. I checked the WID, by echoing. If I run it as script it returns blank. If I run it manually, it is giving a windows id.

Second line of the program is not able to get the Windows Id  if I run it as script.

Offline

#5 2018-12-24 15:57:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Problem in script

I suspect it may take termite a moment to start up and/or properly set the name.  As an initial test of this, I'd put a sleep command between launching termite and the second command.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2018-12-24 17:39:08

rasr11
Member
Registered: 2012-03-26
Posts: 39

Re: Problem in script

Trilby wrote:

I suspect it may take termite a moment to start up and/or properly set the name.  As an initial test of this, I'd put a sleep command between launching termite and the second command.

I have put sleep 10 before the second line, but that is not giving desired result also.

Offline

#7 2018-12-24 19:49:18

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Problem in script

Log the error output from xdotool:

xdotool search --onlyvisible --name 'calcurse' > ~/xdotool.out 2> ~/xdotool.err

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2018-12-25 14:19:51

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Problem in script

Exactly this (waiting for window to appear) is covered by the man page in the description of options for the search command. But if a 10 second sleep doesn't help, you might have another problem. Also, you can use command chaining (leaving ${args} as exercise for the reader):

xdotool search ${args} windowsize 600 420 windowmove 1320 0

Offline

#9 2018-12-27 04:13:14

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 237

Re: Problem in script

rasr11 wrote:

termite -e calcurse

Termite stops executing script until exit. Execute termite in background with '&' at the end.

Last edited by dimich (2018-12-27 04:14:19)

Offline

#10 2018-12-27 05:34:42

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: Problem in script

Please edit the title of this thread to be something vaguely useful, as opposed to "Problem in script".

Offline

Board footer

Powered by FluxBB