-1

I have this script to launch nmon; I want the window to be aligned on the right of the screen as I launch it. To do so I have the shortcut sup+right that works if done manually but does nothing inside the script. It is very simple:

su
export NMON=MMMmcdt-
nmon
xdotool key ‘super+Right’

Thank you for your help

yhurt
  • 11
  • 2
  • The quotes look wrong: `‘’` instead of `''`. – Benjamin W. Jul 31 '20 at 16:26
  • Used yours, change nothing – yhurt Jul 31 '20 at 16:56
  • The `su` at the start is confusing. You hardly want to run this as root, do you? But it doesn't do that anyway. (Maybe see also https://stackoverflow.com/questions/37586811/pass-commands-as-input-to-another-command-su-ssh-sh-etc) – tripleee Jul 31 '20 at 19:49
  • The traditional way to place a window is to pass a `--geometry` with the coordinates for the window. Not all window managers always respect these, I suspect, but that's what I would try. – tripleee Jul 31 '20 at 19:51

1 Answers1

0

I see two problems there:

  1. running nmon will block - you need to change that to "nmon &" (that is run nmon as a "background process" so it does not block the shell)
  2. you are not ensuring you send the key to the correct window, if you VM is set not to focus newly created windows you will send super+right to a wrong window.

Assuming your Window Manager is set to focus newly open windows, this is a simple fix:

su
export NMON=MMMmcdt-
nmon &
xdotool key ‘super+Right’
krimeo
  • 86
  • 3
  • My window manager doesn't focus on this window, because this script is called by another. How can i use the key command on the terminal where i'm writing it? – yhurt Aug 09 '20 at 15:11