You are not logged in.

#1 2015-07-18 12:17:38

pieceofmoses
Member
Registered: 2015-07-18
Posts: 3

[SOLVED] Cinnamon: script autostart

Hi everyone!
I'm having next issue: I want my system to open the maximized window of Terminal (gnome-terminal) in the second workspace on every boot  automatically. I found devilspie package for doing "second workspace and maximized" part of work, so I wrote a small script for devilspie:

(if 
  (is (application_name) "Terminal") 
  (begin
       (set_workspace 2)
       (maximize)
  )
)

While devilspie is running, every Terminal I'll open will act the same way. I don't know how to make it work just for the first instance of Terminal, so I decided to write another small script for running devilspie -> opening terminal according to the rules above -> and killing devilspie to let me work comfortably later:

/bin/devilspie &
/bin/gnome-terminal &
sleep 1
kill $(pidof devilspie)

Everything works if I start this script manually from the terminal. But now, when I try to add it to "Startup applications" (add->command-> sh ~/terminal.sh) with delay or without it, after reboot nothing happens (but it just looks like "more delay -> cinnamon desktop appears after longer time"). I also tried to add this script to /etc/profile.d, but result is exact the same as trying "startup applications" way.

So can anybody give me an advice, how to execute this script right after cinnamon environment is fully loaded? Or there are much easier ways to reach the desired effect? smile

P.S. I use LightDM, if it does matter.
P.P.S. My english is so russian - I'm sorry for possible silly mistakes smile

Last edited by pieceofmoses (2015-07-26 08:28:30)

Offline

#2 2015-07-18 15:24:48

Malkymder
Member
Registered: 2015-05-13
Posts: 258

Re: [SOLVED] Cinnamon: script autostart

Why not check if terminal is open and if not use this to open it with the geometry option

#!/bin/bash
ps cax | grep 'gnome-terminal' > /dev/null

if [ $? -ne 0 ]; then
    gnome-terminal --geometry 73x31+100+300
else
    gnome-terminal
fi

PS your english was fine smile

Edit: fixed a typo

Last edited by Malkymder (2015-07-18 15:58:53)

Offline

#3 2015-07-19 07:11:30

pieceofmoses
Member
Registered: 2015-07-18
Posts: 3

Re: [SOLVED] Cinnamon: script autostart

Thank you Malkymder! This solution is more 'native' than using utils from outer space, but if I understood this right, through the .sh script you can't manipulate the workspaces? I've found "switch-workspace" signal in the Cinnamon API documentation (http://developer.linuxmint.com/referenc … -workspace), but it's something complicated for me and obviously it will be easier to use devilspie in this case smile
So the main question remains: is there a way to add any of this .sh scripts in the 'right point' of startup process, where desktop is loaded and ready to do manipulations with windows/workspaces? (I surely know this way must exist, but I don't see it smile)

Offline

#4 2015-07-19 14:57:13

Malkymder
Member
Registered: 2015-05-13
Posts: 258

Re: [SOLVED] Cinnamon: script autostart

You could Look at wmctrl which also offers to postion in a specific desktop using the -t option

sudo pacman -S wmctrl
man wmctrl

Offline

#5 2015-07-19 16:18:59

Malkymder
Member
Registered: 2015-05-13
Posts: 258

Re: [SOLVED] Cinnamon: script autostart

Sure isn't perfect but should get you going ...

#!/bin/bash
ps cax | grep 'gnome-terminal' > /dev/null

if [ $? -ne 0 ]; then
    gnome-terminal --geometry 73x31+100+300
    PID=$( pgrep gnome-terminal ) # find the PID 
    WID=$( wmctrl -l -p | grep "$PID" | head -1 | awk '{print $1}' ) # Parse the Window ID using PID as a filter
    wmctrl -i -r $WID  -t 2 # Reposition window to specific desktop
else
    gnome-terminal
fi

edit: forgot to leave --geometry for the window size though you could use wmctrl as well to resize the window

Last edited by Malkymder (2015-07-19 16:25:44)

Offline

#6 2015-07-26 08:27:00

pieceofmoses
Member
Registered: 2015-07-18
Posts: 3

Re: [SOLVED] Cinnamon: script autostart

Hello again! I've been away from my system for some time and didn't change anything, but today the problem was solved, so this is what I say:

I just played a bit with Cinnamon autostart and found that its "Startup applications" doesn't recognize "~/" paths. So I put in there an absolute "/home/username/" path to the script, and after re-login everything worked! smile
So now autostart is set as: "add->command-> /home/USERNAME/terminald2.sh"
Also I increased initial 'sleep' parameters a bit due to timing issues during the boot (looks like devilspie loads longer than I imagined):

/bin/devilspie &
sleep 5
/bin/gnome-terminal &
sleep 1
kill $(pidof devilspie)

Thanks again, Malkymder, your script is so fundamental! smile
Despite my decision was to leave that work to my script, I think your one is a good alternative, so others may find it very useful!

[SOLVED]

Last edited by pieceofmoses (2015-07-26 08:31:45)

Offline

Board footer

Powered by FluxBB