Deviant Login Shop  Join deviantART for FREE Take the Tour
×



Details

Submitted on
February 1, 2013
File Size
35.3 KB
Link
Thumb
Embed

Stats

Views
548
Favourites
3 (who?)
Comments
56
Downloads
35
×
Workspace indicator script for BE::Shell by Hombremaledicto Workspace indicator script for BE::Shell by Hombremaledicto

Credits


A script for BE::Shell by :iconhombremaledicto: and :icongiancarlo64:.
The script displays the current workspace number inside a monitor icon.
The archive includes a monitor icon you can resize, and other ones already scaled ( 60 x 60, 48 x 48, 32 x 32 ).


Instructions



  • Download the archive, extract the folder, and move it to your be.shell scripts dir ( on kubuntu: ~/.kde4/share/apps/be.shell/scripts/ ,
    while on certain distributions the path might be ~/.kde4/share/apps/be.shell/scripts/ )
    If the scripts folder is missing, create it.

  • Open a terminal inside the same dir of the script, and give it permissions to be executable: chmod +x workspace.sh

  • Create an applet in your be.shell's config, with the following attributes:

    [workspace]
    Exec=/home/YourUser/.kde/share/apps/be.shell/scripts/workspace/workspace.sh
    PollInterval=1000
    Type=Label

    Remember: the path in Exec must be the same where you placed the script!

  • Add the applet to the Applets list of a panel of your choice.

  • Reload the config


Further options are available through the script: you can change font color, padding, or the icon.
You can also resize the monitor.png icon to the size you prefer( with gimp or converseen).
Just remember to edit the other variables, as explained in the workspace script.
In case you use it in a panel with other applets, edit you BE::Shell's theme, adding:


       #NameOfTheApplet
       {
       padding-left: 10px /* just as an example*/
       padding-right: 10px /* same as over*/
       }



inspiration took from: [link]
Add a Comment:
 
:iconsienardesign:
SienarDesign Featured By Owner Feb 2, 2013
type this into bash:

xprop -root -spy _NET_CURRENT_DESKTOP | head -2

now change the desktop, see what happens.
Reply
:iconhombremaledicto:
Hombremaledicto Featured By Owner Feb 2, 2013
Thank you sir!

Have already tried it, but it starts counting desktop from 0.
I've thought it might be elaborated whithin a variable( or an if condition)
to start from 1, but did not worked (the "number" is a string).
So i've chosen to use qdbus.

But you're ofc more used than me....any tip?
Reply
:iconsienardesign:
SienarDesign Featured By Owner Feb 2, 2013
The above command will esp. wait until the desktop changes, print the (new) current Desktop and exit.
You can use that output as parameter to another (bash) function or put it into a variable:

NET_CURRENT_DESKTOP="`xprop -root -spy _NET_CURRENT_DESKTOP | head -2 | tail -1`"

Then get the number out of it and increase it by one:
NET_CURRENT_DESKTOP="${NET_CURRENT_DESKTOP#* = }"
NET_CURRENT_DESKTOP=$((NET_CURRENT_DESKTOP+1))

(this is bashfu and will unlikely work with eg. dash)

echo $NET_CURRENT_DESKTOP

If you pass write the result (plus some static html) into a FiFo (see the daemon script body), you'll never have to poll the current desktop and it will change instantly =)
Reply
:iconhombremaledicto:
Hombremaledicto Featured By Owner Feb 4, 2013
Great idea!

First time trying to do something like this,
i've used it as in the topfeeder example for the fifo script...
Prolly got it wrong, still no working ;P

Anyway i'll keep trying to edit the script and see,
till i'll get it working :)
Reply
:iconsienardesign:
SienarDesign Featured By Owner Feb 5, 2013
Just ask me - Rob apparently got it as well =)
Reply
:iconhombremaledicto:
Hombremaledicto Featured By Owner Feb 6, 2013
Are you referring to his calendar script ?
Or another?
I heard him telling about the idea to use the fifo one
for his workspace indicator, dunno if he already did it
(didn't hear him since sunday, if my memory isn't fooling me).

The problem is that using the xprop command, i have to wait a long time
until the script displays the right desktop number.
About the fifo: how to use it exaclty?
By importing the fifo.daemon inside the workspace script
( and i guess the previous code should be included in a function)?

Or - by creating a tmp file, and a control cycle which recursively check
if the variable is the same (if it's the case just reads the file), and
if it's not prints the variable to the output and to the file?
This should be the approach that Rob used in the calendar script i mentioned
above.
Reply
:iconsienardesign:
SienarDesign Featured By Owner Feb 6, 2013
yes, calendar.

you don't have to wait at all using this.
xprop just sits there and waits until you change the desktop and the property changes.

then it prints the new desktop which you use to update the label and then you restart the xprop call for the next round (you could also add a small delay to catch the user scrolling through his desktops)

if you source the be.fifo.daemon corpus into your script, you only have to implement "daemon_func" as what is actually running and get a complete daemon which you can start and stop (and it also creates a fifo to be addressed from be.shell), yes.

We might need a "ask Sienar" irc session (on freenode, i assume?) with everyone interested in this.

Do not follow the create/read temporary file path - every I/O op is slow. This has nothing to do with fifos.
Reply
:iconhombremaledicto:
Hombremaledicto Featured By Owner Feb 8, 2013
Another thing i wanted to ask you,
i remembered just today, after a question from Lars.
I know this is not a feature request topic on the BE::Shell forum, but...

Anyway: is it possible to have a label with an additional exec?
I mean: one that is updated by a script, and has an associated action
when clicked. Would be the holy grail to create custom applets
for kiddies like me!

I know that can be done with buttons ( the qdbus calls for icons/tooltip
and Menu/MenuUpdater entries AFAIK) but it's slow.
Reply
(1 Reply)
Hidden by Owner
:iconhombremaledicto:
Hombremaledicto Featured By Owner Feb 7, 2013
I've read your conv with Rob about the calendar.
From that i've tried to import(with source) the FiFo.daemon,
incorporating all previous code into the daemon_func() function,
and linking the fifo in the config, but ofc (doubts) this won't work.
Yet nothing that launch the script every tot mins. So nothing
that updates the FiFo (but i don't know much about how a FiFo is
supposed to work).

Sorry for being redundant with the same question,
but i'm not sure how this procedure has to be done.

Anyway: any chance to see you on IRC ? :)
Reply
(1 Reply)
Add a Comment: