diff --git a/docs/wormc.md b/docs/wormc.md index 82384a2..1c75bd6 100644 --- a/docs/wormc.md +++ b/docs/wormc.md @@ -10,30 +10,30 @@ A command can have any number of parameters. In theory, all these parameters are Numbers are always in decimal. Always. There are no exceptions to this rule; colors are also in plain decimal. Eg, this is invalid: ``` -$ wormc frame-pixel #00ffff +$ wormc frame-pixel #ff00ffff ``` -Instead, you could use on posix shells `$((16#00ffff))` and have the shell expand it for you. For readability purposes, this is recommended and will be used in this sheet for examples; in fish, this is `(math 00ffff)`. +Instead, you could use on posix shells `$((16#ff00ffff))` and have the shell expand it for you. For readability purposes, this is recommended and will be used in this sheet for examples; in fish, this is `(math ff00ffff)`. -Before we begin, finally, a note on X11 colors: We use the 3 byte format RRGGBB in our examples. However, transparency is tacked on to the X11 protocol but it's part of the color. While this is technically implementation dependent because it's not part of the X standard, both Xorg and Xephyr seem to use the format AARRGGBB. If you want control over opacity and are running a compositor use this format, unless you know your X server uses a different one. +Before we begin, finally, a note on X11 colors: While the 3 byte format RRGGBB works in most cases, it's been observed that some compositors assume the 4 byte format AARRGGBB. As a result, we use the AARRGGBB format in the documentation and for all default values and it's recommended you do the same. If you're not using a compositor it's not likely to be an issue, however. Here is the full list of commands:
### `border-active-pixel(uint)` -Sets the border color for the currently active client. Ex: `wormc border-active-pixel $((16#00ffff))` +Sets the border color for the currently active client. Ex: `wormc border-active-pixel $((16#ff00ffff))` ### `border-inactive-pixel(uint)` -Sets the border color for all inactive clients. Ex: `wormc border-inactive-pixel $((16#000000))` +Sets the border color for all inactive clients. Ex: `wormc border-inactive-pixel $((16#ff000000))` ### `border-width(uint)` Sets the border width for all clients, active or not. Ex: `wormc border-width 5` ### `frame-active-pixel(uint)` -Sets the color of the frame (titlebar) for the active window. Ex: `wormc frame-active-pixel $((16#123456))` +Sets the color of the frame (titlebar) for the active window. Ex: `wormc frame-active-pixel $((16#ff123456))` ### `frame-inactive-pixel(uint)` -Sets the color of the frame (titlebar) for all windows that are inactive. Ex: `wormc frame-inactive-pixel $((16#222222))` +Sets the color of the frame (titlebar) for all windows that are inactive. Ex: `wormc frame-inactive-pixel $((16#ff222222))` ### `frame-height(uint)` Sets the height of the frame / titlebar for all clients, active or not. Ex: `wormc frame-height 20` ### `text-active-pixel(uint)` -Sets the color of the text drawn on the titlebar / frame for active windows. Ex: `wormc text-pixel $((16#ffffff))` +Sets the color of the text drawn on the titlebar / frame for active windows. Ex: `wormc text-pixel $((16#ffffffff))` ### `text-inactive-pixel(uint)` -Sets the color of the text drawn on the titlebar / frame for inactive windows. Ex: `wormc text-pixel $((16#000000))` +Sets the color of the text drawn on the titlebar / frame for inactive windows. Ex: `wormc text-pixel $((16#ff000000))` ### `gaps(uint)` Sets the gaps to the specified amount. When in tiling mode, this distance is reserved between the inside parts of windows. See struts for the outside. Ex: `wormc gaps 5` ### `text-font(string)` diff --git a/examples/rc b/examples/rc index 43fba0f..34d9ae7 100644 --- a/examples/rc +++ b/examples/rc @@ -10,10 +10,30 @@ exec sxhkd -c ~/.config/worm/sxhkdrc & wormc border-width 6 -# These add support for pywal -# wormc border-active-pixel $((16$(sed -n '4p' .cache/wal/colors))) -# wormc border-inactive-pixel $((16$(sed -n '5p' .cache/wal/colors))) -# wormc background-pixel $((16$(sed -n '6p' .cache/wal/colors))) +## pywal support +# # CONFIGURE +# pywal_active_index="3" # color3 +# pywal_inactive_index="4" # color4 +# +# # CODE +# contrast_text_for () { +# # Formula from: +# # https://stackoverflow.com/questions/596216/formula-to-determine-perceived-brightness-of-rgb-color +# # https://www.w3.org/TR/AERT/#color-contrast +# if perl -e "exit ((1 - (0.299 * $((16#${1:0:2})) + 0.587 * $((16#${1:2:2})) + 0.114 * $((16#${1:4:2}))) / 255) > 0.5)"; then +# echo $((16#FF000000)) +# else +# echo $((16#FFFFFFFF)) +# fi +# } +# pywal_active="$(sed -n $(($pywal_active_index + 1))p ~/.cache/wal/colors | tail -c +2)" +# pywal_inactive="$(sed -n $(($pywal_inactive_index + 1))p ~/.cache/wal/colors | tail -c +2)" +# wormc border-active-pixel $((16#FF$pywal_active)) +# wormc border-inactive-pixel $((16#FF$pywal_inactive)) +# wormc frame-active-pixel $((16#FF$pywal_active)) +# wormc frame-inactive-pixel $((16#FF$pywal_inactive)) +# wormc text-active-pixel $(contrast_text_for $pywal_active) +# wormc text-inactive-pixel $(contrast_text_for $pywal_inactive) wormc layout tiling wormc struts 75 20 20 20 diff --git a/src/wm.nim b/src/wm.nim index 319b96d..a103732 100644 --- a/src/wm.nim +++ b/src/wm.nim @@ -147,14 +147,14 @@ proc initWm*(): Wm = netAtoms: netAtoms, ipcAtoms: getIpcAtoms dpy, config: Config( - borderActivePixel: 0x7499CC, - borderInactivePixel: 0x000000, + borderActivePixel: uint 0xFF7499CC, + borderInactivePixel: uint 0xFF000000, borderWidth: 1, - frameActivePixel: 0x161821, - frameInactivePixel: 0x666666, + frameActivePixel: uint 0xFF161821, + frameInactivePixel: uint 0xFF666666, frameHeight: 30, - textActivePixel: 0xffffff, - textInactivePixel: 0x000000, + textActivePixel: uint 0xFFFFFFFF, + textInactivePixel: uint 0xFF000000, textOffset: (x: uint 10, y: uint 20), gaps: 0, buttonSize: 14,