You are not logged in.

#1 2010-06-21 20:32:00

warnec
Member
From: Poland
Registered: 2009-06-22
Posts: 166

[SOLVED]Script to replace compiz with metacity and the other way round

Hi. I would like You guys to help me. I don't want to use fusion-icon (many complex reasons I wouldn't like to state here, just please take it for granted) and I'd like to bind a key combination for a command which would let me replace compiz with metacity and the other way round. So I think I need a script.

What I'd need:

detect if compiz is running
yes -> metacity --replace
no -> compiz --loose-binding --replace

Can You help? wink

Last edited by warnec (2010-06-23 19:38:46)

Offline

#2 2010-06-22 09:00:07

PirateJonno
Forum Fellow
From: New Zealand
Registered: 2009-04-13
Posts: 372

Re: [SOLVED]Script to replace compiz with metacity and the other way round

here's a rough, untested stab at it:

#!/bin/sh
if pgrep -x metacity &> /dev/null; then
  compiz --loose-binding --replace &
else
  metacity --replace &
fi

the pgrep call might need to be a bit more specific for a multi-user system


"You can watch for your administrator to install the latest kernel with watch uname -r" - From the watch man page

Offline

#3 2010-06-22 09:43:33

warnec
Member
From: Poland
Registered: 2009-06-22
Posts: 166

Re: [SOLVED]Script to replace compiz with metacity and the other way round

it doesn't seem to work. When I've got Compiz running and use this script, the screen flickers, but Compiz still works. I suspect

compiz --loose-binding --replace

is ran even if Compiz is running.

Offline

#4 2010-06-22 13:14:32

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,358

Re: [SOLVED]Script to replace compiz with metacity and the other way round

dbus-send --print-reply --type=method_call --dest=org.freedesktop.compiz /org/freedesktop/compiz/dbus/screen0 org.freedesktop.compiz.list | wc -l

This will return 0 if compiz isn't running.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#5 2010-06-22 13:31:43

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: [SOLVED]Script to replace compiz with metacity and the other way round

#!/bin/bash

if pgrep compiz > /dev/null; then
    metacity --replace &
else
    compiz --loose-binding --replace ccp &
fi

This should work


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#6 2010-06-23 16:56:21

warnec
Member
From: Poland
Registered: 2009-06-22
Posts: 166

Re: [SOLVED]Script to replace compiz with metacity and the other way round

The scripts by mojlac024 replaces compiz by metacity when compiz is running, but when metacity is running it doesn't bring compiz back.

How to incorporate that test:

dbus-send --print-reply --type=method_call --dest=org.freedesktop.compiz /org/freedesktop/compiz/dbus/screen0 org.freedesktop.compiz.list | wc -l

into the script?

PS.:
When compiz is running, it prints 1. But when compiz is not running, it prints:

Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.compiz was not provided by any .service files
0

So a simple logical test of "is this 0 or not?" won't work, I'm afraid.

Last edited by warnec (2010-06-23 17:01:44)

Offline

#7 2010-06-23 17:32:05

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: [SOLVED]Script to replace compiz with metacity and the other way round

if [ $(dbus-send --print-reply --type=method_call --dest=org.freedesktop.compiz /org/freedesktop/compiz/dbus/screen0 org.freedesktop.compiz.list 2>/dev/null | wc -l) -eq 0 ]; then
    metacity --replace &
else
    compiz --loose-binding --replace ccp &
fi

Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#8 2010-06-23 18:56:08

warnec
Member
From: Poland
Registered: 2009-06-22
Posts: 166

Re: [SOLVED]Script to replace compiz with metacity and the other way round

it just stops compiz and starts it again.

EDIT: Wait! It just noticed it works fine.
The only thing which caused me to think it wasn't working was my stupidity - in CCSM I bound Shift+F11 to the script, so the shortcut called the script only when compiz was running - with metacity, ccsm isn't working.

Thanks for all Your help, guys.

for binding shift+f11 to the script, I used xbindkeys.

Last edited by warnec (2010-06-23 19:38:31)

Offline

Board footer

Powered by FluxBB