This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Running kwin with khotkeys only

Tags: None
(comma "," separated)
mercure
Registered Member
Posts
4
Karma
0

Running kwin with khotkeys only

Wed Jul 22, 2015 3:27 pm
Hi,
I'm trying to get a very basic windows manager using only kwin and khotkeys (user can only interact with the application we start using hotkeys (ctrl+F1/F4)).
Currently I start kwin from xinitrc with only a terminal window (terminal windows will be removed once the hotkeys work).

[ -x /usr/bin/xterm ] && /usr/bin/xterm -geometry 80x50-50+150 &
exec /usr/bin/kwin

The problem is that I don't have my hotkeys working and I can't get khotkeys to start from the command line.
I can get the hotkeys to work using "kcmshell4 khotkeys" and just click ok but this is not practical (though I gives me hope that a solution exists).

startkde works, but then i get all the plasma and desktop features I need to remove.

Is there a way to start khotkeys from command line?
kcminit khotkeys didn't work

Thanks

I'm on
Centos 6
Qt: 4.6.2
KDE: 4.3.4 (KDE 4.3.4)
KWin: 4.3.4 (KDE 4.3.4)
luebking
Karma
0

Re: Running kwin with khotkeys only

Wed Jul 22, 2015 4:43 pm
you need to run
* kded (with khotkeys module loaded)
* kglobalaccel (as that's what does global shortcuts across all KDE - kwin receives them as any other client from there)
mercure
Registered Member
Posts
4
Karma
0

Re: Running kwin with khotkeys only

Wed Jul 22, 2015 7:26 pm
Thanks
I'm able to load the khotkey module in my terminal window using:
/usr/lib/qt4/bin/qdbus org.kde.kded /kded org.kde.kded.loadModule khotkeys

But where can I put this line to be loaded with kwin?
It doesn't work in my xinitrc
luebking
Karma
0

Re: Running kwin with khotkeys only

Wed Jul 22, 2015 8:03 pm
Two pitfalls:
a) kded must be running (kwin -or any KDE application- would start it implicitly)
b) the dbus server address - it's exported in KDE sessions, but that may fail in your setup.
=> You could fork kded first and then grep the PIDs environment for the server address

Code: Select all
kglobalaccel &
kded &
sleep 1 # safe ./. sorry
DBSB_ADDRESS="`tr '\0' '\n' < /proc/$!/environ | grep -i DBUS_SESSION_BUS_ADDRESS`"
qdbus --address "$DBSB_ADDRESS" org.kde.kded /kded org.kde.kded.loadModule khotkeys
kwin # actually it's not a supersmart idea to use something as complex as kwin to keep the session alive ...
mercure
Registered Member
Posts
4
Karma
0

Re: Running kwin with khotkeys only

Thu Jul 23, 2015 2:30 am
Thanks again
I couldn't find DBUS_SESSION_BUS_ADDRESS in /proc but it is in ~/.dbus/session-bus
it looks like
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-4ydCSVB5dJ,guid=857aef640a9bce0a90a03dea00084624

Try as I might I can't get this to work form command line.
qdbus --address "$DBUS_SESSION_BUS_ADDRESS" org.kde.kded /kded org.kde.kded.loadModule khotkeys
I get Service 'unix:abstract=/tmp/dbus-4ydCSVB5dJ,guid=857aef640a9bce0a90a03dea00084624' is not a valid name
(I also tried with 857aef640a9bce0a90a03dea00084624 or /tmp/dbus-4ydCSVB5dJ ... instead of fulls address)

feels like --address doesn't work?
any idea / alternatives to qdbus
luebking
Karma
0

Re: Running kwin with khotkeys only

Thu Jul 23, 2015 1:15 pm
it's more likely the bus id is wrong/dated - also ~/.dbus/session-bus should be a directory containing some hash-named files containing some bus informations - only one of them will be the correct one.

DBUS_SESSION_BUS_ADDRESS is *not* supposed to be found in proc, but in the environment of some (KDE) applications.


Anyway, you will require some session dbus daemon to be running ("ps aux | grep -i dbus-daemon") and in doubt pass that address to qdbus (or dbus-send)
The address switch generally works, don't worry ;-)
mercure
Registered Member
Posts
4
Karma
0

Re: Running kwin with khotkeys only

Thu Jul 23, 2015 5:50 pm
Ok, I've got something that works turns out that my main problems was to figure out that the actual syntax of qdbus is:
qdbus --address="$DBUS_SESSION_BUS_ADDRESS ...

So now my xinitrc looks like this
...
${HOME}/bin/qdbusaddress.sh ${DISPLAY} &
exec /usr/bin/kwin

where qdbusaddress.sh is
Code: Select all
if [[ $# -ne 1 ]]; then
    echo usage: qdbusaddress.sh targetdisplay
    exit 1
fi
export DISPLAY=$1

#find the qdbus file that manages the selected display
#and source it
QDBUS_SESSION_FILES=`find ${HOME}/.dbus/session-bus -type f`
for a in $QDBUS_SESSION_FILES;
do
  grep "display $1" $a > /dev/null && source $a
done

COUNTER=0
#run qdbus to load khotkeys every 1 second until it loads or fails after 30s
if [ ! -z ${DBUS_SESSION_BUS_ADDRESS} ]; then
  while [  ${COUNTER} -lt 30 ]; do
                sleep 1
                qdbus --address="${DBUS_SESSION_BUS_ADDRESS}" org.kde.kded /kded org.kde.kded.loadModule khotkeys > /dev/null
                if [ $? -eq 0 ]; then
                        echo "khotkeys is loaded"
                        exit 0
                fi
    let COUNTER=COUNTER+1
  done
fi

echo error: khotkeys not loaded counter=${COUNTER} address=${DBUS_SESSION_BUS_ADDRESS}
exit 1



This seems to hold for now, though I hope I don't get into trouble with the files in .dbus/session-bus -type.
I'm assuming they are always available before I reach the call to kwin in xinitrc?

Thanks a lot for the help :-)
luebking
Karma
0
D'ohh, i forgot to strip the var name =)

The session bus availability depends on your login system, ie. systemd/logind (and consolekit?) will automatically provide a session bus and KDE applications should afair launch one implicitly - otherwise you've to (better) launch one by hand, eg. source /etc/X11/xinit/xinitrc.d/30-dbus.sh
Code: Select all
#!/bin/bash

# launches a session dbus instance
if [ -z "${DBUS_SESSION_BUS_ADDRESS-}" ] && type dbus-launch >/dev/null; then
  eval $(dbus-launch --sh-syntax --exit-with-session)
fi


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]