0

I have this script:

#!/bin/sh

cd ~/.devilspie && devilspie Minimize.ds
pkill devilspie

exit 0

The first command runs absolutely fine, but in the second line where it needs to kill the process, it doesn't do so. If I run the command in terminal it works as intended but not in the script. Is there anything wrong with the script.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227

2 Answers2

1

You have to run devilspie in background. If you don't do this, the script will not reach the line with pkill until you terminate devilspie some other way.

You may start devilspie in the background by adding & to the end of the command:

cd ~/.devilspie && devilspie Minimize.ds &
Kusalananda
  • 320,670
  • 36
  • 633
  • 936
metallic
  • 346
  • 1
  • 4
  • @Kusalananda as I understood from comments below first answer, the script script doesn't get to the next line. It stops at devilspie. So that is why I suggested that running it in background mod could be the solution. – metallic Nov 01 '18 at 14:09
  • Adding an explanation to the answer (and not just "do this") helps them understand and learn. – Kusalananda Nov 01 '18 at 14:15
0

You can use these commands:

pkill -9 devilspie 
or 
pgrep devilspie | xargs kill -9 
or
killall devilspie
Ijaz Ahmad
  • 7,146
  • 5
  • 32
  • 45