Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to draw indicator as polygon #258

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Zabot
Copy link

@Zabot Zabot commented Mar 27, 2022

Description

I needed a hexagon unlock indicator for my config, thought it turned out pretty neat and was worth sharing. This adds three new config options.

  • --polygon-sides=n enables drawing a regular polygon instead of a circle for the indicator. It defaults to 0, which draws a circle, and can be any integer greater then 2.
  • --polygon-offset=d specifies a rotation in degrees to apply to the polygon. At zero offset the first vertex is at (ind_x+radius,ind_y).
  • --polygon-highlight={0,1,2} defines the highlight mode while typing. 0 highlights a random edge on each keystroke. 1 highlights sequential edges walking clockwise around the indicator. 2 walks counter clockwise. The edge to highlight is based on the buffer position, so backspacing characters reverses the direction of rotation.

The value of --radius is the center to vertex distance of the polygon. --line-*, --inside-*, and --ring-* are all respected. Separators are not drawn.

Screenshots/screencaps

custom
default

Release notes

Notes: Added config options to draw indicator as a polygon.

@Raymo111
Copy link
Owner

This is SO COOL. I'll review and merge soon!

Copy link
Owner

@Raymo111 Raymo111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! This was a static review, just a couple of code points to fix. Once they're updated I'll do a full test and then approve+merge!

i3lock.1 Outdated Show resolved Hide resolved
i3lock.1 Outdated Show resolved Hide resolved
i3lock.c Outdated Show resolved Hide resolved
i3lock.c Outdated Show resolved Hide resolved
i3lock.c Outdated Show resolved Hide resolved
i3lock.c Outdated Show resolved Hide resolved
unlock_indicator.c Outdated Show resolved Hide resolved
unlock_indicator.c Outdated Show resolved Hide resolved
unlock_indicator.c Outdated Show resolved Hide resolved
unlock_indicator.c Outdated Show resolved Hide resolved
@Zabot Zabot force-pushed the polygon-indicator branch 2 times, most recently from a4a6bcf to 8c22426 Compare August 6, 2022 07:10
@Zabot Zabot requested a review from Raymo111 August 6, 2022 07:15
Copy link
Owner

@Raymo111 Raymo111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good changes, couple more. Please add more commits instead of amending so it's easier for me to review, thanks!

@@ -93,6 +93,10 @@ _i3lock() {
"--bar-pos"
"--bar-count"
"--bar-total-width"
# Polygon indicator
"--polygon-sides"
"--polygon-offset"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this

@@ -444,6 +444,20 @@ Sets the number of minibars to draw on each screen.
.B \-\-bar\-total\-width
The total width of the bar. Can be an expression.

.TP
.B \-\-polygon\-sides
Draw the indicator as a regular polygon instead of a circle.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should document the required arg (number of sides, in addition to current info here)

if (sscanf(arg, "%d", &polygon_sides) != 1)
errx(EXIT_FAILURE, "polygon-sides must be a number\n");
if (polygon_sides < 3)
errx(EXIT_FAILURE, "polygon-sides must be greater then 2 or 0\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't be 0 either

case 405:
arg = optarg;
if (sscanf(arg, "%lf", &polygon_rotation) != 1)
errx(1, "polygon-rotation must be a number\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use EXIT_FAILURE

case 406:
arg = optarg;
if (sscanf(arg, "%d", &polygon_highlight) != 1)
errx(1, "polygon-highlight must be a number\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use EXIT_FAILURE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants