dzen

User avatar
stark
MILF
Posts: 521
Joined: Sat Sep 27, 2014 6:38 pm
Location: Arpanet
Contact:

Re: dzen

Unread post by stark » Fri May 08, 2015 7:50 pm

You can use lemonbar with hlwm here are few example ( change `bar` to `lemonbar` and remove the non-hlwm specific stuff assuming you don't use mpd ):

http://unek.blinkenshell.org/dotfiles/panel
http://dotshare.it/dots/736/1/raw/
If you can do it go ahead and do it, if you can't do it then don't even criticize it. - gingerdesu

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: dzen

Unread post by dkeg » Fri May 08, 2015 7:57 pm

I have not changed bar to lemonbar in my scripts, but pretty sure I did a git pull since the name change. I'll have to double check that tonight

Work hard; Complain less

User avatar
stark
MILF
Posts: 521
Joined: Sat Sep 27, 2014 6:38 pm
Location: Arpanet
Contact:

Re: dzen

Unread post by stark » Fri May 08, 2015 8:04 pm

Yup, two notable changes are the binary name and the `-f` flag handling.
If you can do it go ahead and do it, if you can't do it then don't even criticize it. - gingerdesu

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dzen

Unread post by rhowaldt » Sat May 09, 2015 3:46 pm

dzen's textwidth thing calculates the pixels in bitmap fonts to determine the width of the output, so you can align it right with some maths. however, it doesnt look at icons (xbm) and it doesnt work with xft, which sucks. however, somebody (from Arch, as always) made xftwidth. worth checking out if you dont know it already: https://bbs.archlinux.org/viewtopic.php?id=180244
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dzen

Unread post by rhowaldt » Tue May 12, 2015 11:47 pm

had some success with my dzen-config in making it update quickly and thus display both the elapsing time of a playing song (through moc) as well as immediate updates of the volume level in the statusbar. however, the only way of doing this is through an infinite loop, and it seems that my CPU isn't particularly enjoying me querying mocp and amixer repeatedly in order to stay up-to-date. so in other words: it works wonderfully but doesn't make my CPU happy.

so i was wondering: what would be the best way to go about this? the only way to get info out of moc seems to be to query it (meaning: it doesn't seem to be possible to have moc send a signal out anywhere on song-change for example. as for the volume: since it works on keypress, it might be possible to have that set to trigger an update of sorts...

hoping somebody has some clever ideas :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

Re: dzen

Unread post by pidsley » Wed May 13, 2015 12:41 am

^ Not really a clever idea, but conky has moc and volume calls built in -- you might look at using it instead of dzen, or using a simple conky to pipe output to dzen. I know this probably seems like bloat and you would rather do it the hard way, but that script you are using now is kind of a monster anyway.

https://wiki.archlinux.org/index.php/Dz ... _and_Conky

(see "man conky" or the conky docs on sourceforge for the appropriate moc and mixer information)

http://conky.sourceforge.net/variables.html

I still don't think this will give you instantaneous updates (it will be limited by the conky update frequency.) If you absolutely need instant updates you might try looking at using a fifo the way monsterwm does its bar (don't ask me to explain how to do this, because I barely know what a fifo is.)

https://gist.github.com/c00kiemon5ter/1905427

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: dzen

Unread post by machinebacon » Wed May 13, 2015 6:32 am

rhosey, if you allow me a stupid comment: why the fuck shall somebody know how much time has elapsed into a song? :blush:

I know, everybody can do whatever the fuck he wants, I just ask to understand. Any music player is using a tad of CPU (yes, even Stanislaus' mpg123/321, whereas 123 is a bit heavier on CPU than 321), so mocp cannot be much lighter in this respect. Would mpd not do what you want? It uses the control through mpc, and this fucker is light, I mean really light.
..gnutella..

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dzen

Unread post by rhowaldt » Wed May 13, 2015 1:25 pm

@pids: thanks, that is indeed a good suggestion and you've covered all my concerns with it (the idea of bloat etc), but it might be the best way to go about it. but yeah, i kinda just wanted to try the hard way :)
@mb: agreed, which is why i decided to just not display the elapsed time. however, i'd still like the song to change on my bar when it changes on MOC, so leaving the elapsed time out did not solve my issue there. btw, the reason i wanted the elapsed time is simply because i like to know how much time is left in the song :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: dzen

Unread post by machinebacon » Wed May 13, 2015 1:42 pm

^ In your heart you're still a Crunchbanger :D
..gnutella..

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dzen

Unread post by rhowaldt » Wed May 13, 2015 4:57 pm

<insert diatribe on how the original meaning of the word "Crunchbanger" has been corrupted after the Psychedelic Shitstorm etc etc etc ad nauseam>
*silently cries inside* ;_;
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: dzen

Unread post by GekkoP » Wed May 13, 2015 5:13 pm

^ Damn, and I wasn't even there when all that happened.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: dzen

Unread post by machinebacon » Wed May 13, 2015 5:35 pm

^ Rhosey wants to have all relevant data (weather in Urumuqi in Fahrenheit multiplied with the Pi of Celsius, CPU fan speed divided by anus, remaining time in kilograms, the exchange rate of Vietnamese Dong to Hungarian Forint, all unread posts on the #! forums, number of spam in hotmail.com and the whole file tree of his Windows 7 partition) compacted into a bar that is piped through a conky into OSD-notifyd via morsecode, but silenting whenever a song name contains a whitespace, that's Crunchbangy enough for me :D
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: dzen

Unread post by GekkoP » Wed May 13, 2015 6:09 pm

^ :D fantastic.

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dzen

Unread post by rhowaldt » Wed May 13, 2015 9:51 pm

Oh Julesy, you understand me so well <3
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dzen

Unread post by rhowaldt » Thu May 14, 2015 10:57 am

@pids: started reading about named pipes (fifo) due to your mention, and seeing how you said you barely knew anything about them i figured i'd throw you this article that explains the concept pretty well. it also seems the fifo might definitely provide a solution to my issues, so thanks for mentioning it :) >>> http://www.linuxjournal.com/content/usi ... fifos-bash

as for the whole "doing it the hard way" thing, i think i basically just want to know how the fuck it works. i would rather figure out how to do it myself through simple bash scripts instead of having to resort to an application, which would teach me less. i might still return to the application in the end simply because, hey, maybe it was written in C and has a 10000x more efficient way of doing this shit, but at least i'd know more about How Shit Works.
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: dzen

Unread post by machinebacon » Thu May 14, 2015 5:40 pm

Rho, so you want:
- mocp song title
- mocp time info
- volume level
- date and time
- updating every second without being in a loop

Is this true so far? Something else?
..gnutella..

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dzen

Unread post by rhowaldt » Thu May 14, 2015 10:44 pm

^ wifi.
it needs to update more than every second to keep in sync with moc (or at least, that is my experience. what if moc songcount started half a second later than dzen's update? you would go askew). i removed the song time from my config for now, fuck it, let's just keep it simple and display the title.

i have moc update almost working through moc's OnSongChange parameter in the config file. you can set it to run a script. my script sends the song info to a fifo, which dzen then reads out. the only problem is that i need to "initialize" the pipe somehow, so i can read a value out for the first time when dzen runs, or it won't show shit until the playing song changes (no value? no display). so not perfect yet, but at least moc and dzen can communicate directly without conky coming in between them.

volume update through buttons should work in the exact same manner as moc, just configure WM to execute a script on keypress volup/down which sends the new volume value to a fifo which is read out by dzen. i believe the fifos are definitely the key to doing this. will continue the tinkering :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dzen

Unread post by rhowaldt » Wed May 20, 2015 11:38 pm

still struggling with fifos (named pipes) to make dzen reflect MOC songchanges, but tonight at last i managed to get a prototype (test-script) to work.

to try this, first off make a script to send moc-data to your fifo. moc cannot send it directly, it only has an option to activate a script, so therefore we do it through the script. this is mine:

Code: Select all

#!/bin/bash
# send signals for songchange and songtop from moc to a fifo
# which is in turn read by dzen panel

pipe=/tmp/moc-dzen_pipe

if [[ "$1" ]]; then
    echo "change-$1" >$pipe
else
	echo "stop" >$pipe
fi
as you can see, it sends $1, which will be the filename of the playing song, with the prefix "change-" (to be able to identify different signals later) to /tmp/moc-dzen_pipe. this is called the messenger-script. the pipe itself does not exist yet, it will be created by the receiver-script. but first, change your moc config:

Code: Select all

OnSongChange = "/home/rhowaldt/.moc/dzen_pipe.sh %f"
obviously change the path. '%f' is the shortcut for the filename in the moc config.

with that set up, here's the receiver script.

Code: Select all

#!/bin/bash

fifo_name="/tmp/moc-dzen_pipe"                  # fifo name

trap "rm -f $fifo_name" EXIT                    # set trap to rm fifo_name at exit

[ -p "$fifo_name" ] || mkfifo "$fifo_name"      # if fifo not found, create

exec 3< $fifo_name                              # redirect fifo_name to fd 3
                                                # (not required, but makes read clearer)
while :; do
    if read -r -u 3 line; then                  # read line from fifo_name
        if [ "${line%%-*}" == 'change' ]; then          
            muz=$(echo "${line##*/}" | sed -e 's_/.*/__' -e 's/\.[^\.]*$//' -e 's/_/ /g')
        elif [ "$line" == 'stop' ]; then
			muz="--stopped--"
		fi
		echo "$muz"
    fi
done | dzen2

exec 3<&-                                       # reset fd 3 redirection

exit 0
the %%#(#(#(*@&-/ shit is bash variable substitution, simply a shortcut instead of using sed to, in this case, separate the 'change-' tag from the actual filename. it is not very important, or what i mean is: you could do it in a different way but this is how i chose to do it.

try running the messenger-script, then running moc. you should get a bar at the top of your screen with the filename. change the song in moc (mocp -f if it saves you switching terminals) and see the song change in your panel, live, bam.

i am still planning to do the same with the volume, which shouldn't be too hard. then all i need to do is get everything working together in one big panel script that holds all the informations.

hope this helps somebody :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
kexolino
Common Boob
Posts: 557
Joined: Sun Jun 16, 2013 1:57 pm

Re: dzen

Unread post by kexolino » Fri May 22, 2015 8:32 pm

I am testing your solution with these:

ws_sig.sh - gets executed on workspace change by fluxbox (Mod4 1 :MacroCmd {Workspace 1} {Exec ~/bin/ws_sig.sh}):

Code: Select all

#!/bin/bash                                                                                                      
pipe=/tmp/ws_pipe
WS=$(xdotool get_desktop)
echo $WS > $pipe
test.sh

Code: Select all

#!/bin/bash                                                                                                      

fifo="/tmp/ws_pipe"
trap "rm -f $fifo" EXIT
[ -p "$fifo" ] || mkfifo "$fifo"
exec 3< $fifo

while true
do
    if read line <$fifo; then
        echo $line
    fi  
done | lemonbar

exec 3<&-

exit 0
The bar shows up with the desired info, but it changes as slowly as if I had a script with a 1 second update interval. Where am I going wrong?

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dzen

Unread post by rhowaldt » Fri May 22, 2015 11:40 pm

to be completely honest Kex, i am not sure. this fifo stuff still baffles me in large part, despite the fact i got it to work in this one instance. i wish i could help you, but i don't see anything wrong with it to my knowledge (which is limited). sorry :/
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

Post Reply