- Notifications
You must be signed in to change notification settings - Fork2
Precision control for polybar modules
License
budlabs/polify
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
See the live action raw uncut demonstration video onyoutube:https://youtu.be/XDUQd4VN4cQ
If you useArch Linux you can getpolify fromAUR.
polify have no dependencies and all you need is thepolify
script in your PATH. Use the Makefile to do asystemwide installation of both the script and the manpage.
(configure the installation destination in the Makefile,if needed)
$ git clone https://github.com/budlabs/polify.git$ cd polify# make install$ polify -vpolify - version: 2019.08.05.1updated: 2019-08-05 by budRich
Forpolify to work, there needs to be at least onemodule of the typecustom/ipc
and the settingenable-ipc
needs to be set to true in the polybar configuration file.
~/.config/polybar/config
[bar/example]enable-ipc = true...[module/polifyModule1]type = custom/ipchook-0 = polify --module polifyModule1...
When polify is executed with only the--module MODULE_NAME
option, all it will do iscat
the content ofthe file:/tmp/polify/MODULE_NAME
(orecho
a blank lineif the file doesn't exist). When this is done from apolybar module it will set the modules text tothelast line of the file.
Any arguments to thepolify
command that doesn't belongto an option, will get redirected (and formatted if neededor requested) to/tmp/polify/MODULE_NAME
. Then the commandpolybar-msg hook MODULE_NAME 1
will get executed bypolify, causing the module to get updated.
EXAMPLE:
$ polify --module polifyModule1 testing one three four
this will first create (or overwrite) the file:/tmp/polify/polifyModule1 with the single line: testing onethree four
then the command:polybar-msg hook polifyModule1 1
isautomatically executed, triggering the first hook toexecute: (polify --module polifyModule1), which in turn willupdate the module with the string: "testing one three four"
The--expire-time SECONDS
option can be used to clear themodule when SECONDS have passed. It is also possible tomanually clear a module with the--clear
option.
The text can be forced to have a specific background,foreground or mouse-button actions. It is also possible toprefix the string with another string, the prefix in turncan have different colors and actions:
EXAMPLE:
$ polify --module polifyModule1 \ --foreground '#FF00FF' \ --background '#000000' \ --rightclick 'notify-send "polify rc"' \ --prefix "test module: " \ --foreground-prefix '#FFF000' \ --background-prefix '#0000FF' \ --leftclick-prefix 'notify-send "clicking prefix"' \ this is the main string$ cat /tmp/polify/polifyModule1%{F#FFF000}%{B#0000FF}%{A1:notify-send "clicking prefix":}test module: %{A}%{F-}%{B-}%{F#FF00FF}%{B#000000}%{A3:notify-send "polify rc":}this is the main string%{F-}%{B-}%{A}
Since only the last line of the file is the one that willbe visible in the bar, it is possible to write and read textto the file and use them to f.i. store the state of amodule. This is conveniently done by using the--msg MESSAGE
option.
polify is shipped with the scriptpolifypop, which canbe used to execute commands on the--msg
line. It will onlyexecute a command if it is prefixed with the wordPOLIPOP. And the first argument topolifypop needsto be the name of the module, it is cool to bind polifypopto a hotkey...
$ polify --module polifyModule1 --msg "mode1" --foreground '#FF0000' this is mode one$ cat /tmp/polify/polifyModule1 | head -1mode1
$ polify --module polifyModule1 --msg "POLIPOP notify-send 'hello pop'" hello bar$ polifypop polifyModule1
polifymodetoggler.sh
#!/bin/bashthisscript="$(readlink -f"$0")"if [[$(polify --module polifyModule1| head -1)= mode1 ]];then polify --module polifyModule1 \ --leftclick"$thisscript" \ --foreground'#00FF00' \ --msg"mode2" \ this is mode twoelse polify --module polifyModule1 \ --leftclick"$thisscript" \ --foreground'#FF0000' \ --msg"mode1" \ this is mode onefi
If you are using multiple polybars you can use the--pid PID
option to specify which polybar process to work with.
polify --module|-o TARGET-MODULE [OPTIONS] [MESSAGE]polify --module|-o TARGET-MODULE [--pid|-p PID] [--foreground|-f COLOR] [--background|-b COLOR] [--leftclick|-l COMMAND] [--rightclick|-r COMMAND] [--middleclick|-m COMMAND] [--scrollup|-u COMMAND] [--scrolldown|-d COMMAND] [--prefix|-e STRING [ [--foreground-prefix|-F COLOR] [--background-prefix|-B COLOR] [--leftclick-prefix|-L COMMAND] [--rightclick-prefix|-R COMMAND] [--middleclick-prefix|-M COMMAND] [--scrollup-prefix|-U COMMAND] [--scrolldown-prefix|-D COMMAND] ] [--expire-time|-t SECONDS] [--msg|-s MESSAGE] [MESSAGE]polify --module|-o TARGET-MODULE [--pid|-p PID] --clear|-xpolify --help|-hpolify --version|-v
--module
|-o
TARGET-MODULE
Name of target module
--pid
|-p
PID
If set the specified polybar PID process will be used.
--foreground
|-f
COLOR
Hexadecimal color value for MESSAGE foreground color.
--background
|-b
COLOR
Hexadecimal color value for MESSAGE background color.
--leftclick
|-l
COMMAND
COMMAND will get executed when MESSAGE is left-clicked
--rightclick
|-r
COMMAND
COMMAND will get executed when MESSAGE is right-clicked
--middleclick
|-m
COMMAND
COMMAND will get executed when MESSAGE is middle-clicked
--scrollup
|-u
COMMAND
COMMAND will get executed when MESSAGE is scrolled up.
--scrolldown
|-d
COMMAND
COMMAND will get executed when MESSAGE is scrolled down.
--prefix
|-e
STRING
PREFIX text
--foreground-prefix
|-F
COLOR
Hexadecimal color value for PREFIX foreground color.
--background-prefix
|-B
COLOR
Hexadecimal color value for PREFIX background color.
--leftclick-prefix
|-L
COMMAND
COMMAND will get executed when PREFIX is left-clicked
--rightclick-prefix
|-R
COMMAND
COMMAND will get executed when PREFIX is right-clicked
--middleclick-prefix
|-M
COMMAND
COMMAND will get executed when PREFIX is middle-clicked
--scrollup-prefix
|-U
COMMAND
COMMAND will get executed when PREFIX is scrolled up.
--scrolldown-prefix
|-D
COMMAND
COMMAND will get executed when PREFIX is scrolled down.
--expire-time
|-t
SECONDS
If set module will get cleared after SECONDS
--msg
|-s
MESSAGE
Will get added to the module text file before the actualmessage/prefix. Can be used to store information such as thecurrent state of the module
--clear
|-x
Clears the module.
--help
|-h
Show help and exit.
--version
|-v
Show version and exit.
Added polifypop.
Initial release.
polify is licensed with theMIT license
About
Precision control for polybar modules