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 support for OpenBSD #325

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

Conversation

landryb
Copy link

@landryb landryb commented Nov 10, 2023

OpenBSD has initial/wip wayland support, so add support for building/using swaylock on OpenBSD. It uses http://man.openbsd.org/auth_userokay for user authentication so integrates well with the various login methods.

There's no wordexp() on OpenBSD:

been able to use swaylock with image=/usr/local/share/backgrounds/xfce/xfce-blue.jpg in ~/.config/swaylock/config swaylock and it does what's expected.

Feedback welcome !

it's already defined in /usr/include/math.h on OpenBSD
sprinkle #if HAVE_WORDEXP where used
include config.h first to only include wordexp.h if needed
OpenBSD doesn't have/need libcrypt or librt
landryb added a commit to landryb/swayidle that referenced this pull request Nov 10, 2023
- like done in swaywm/swaylock#325, provide an alternative for swayidle
  configuration file lookup
- and provide a handrolled config line parser for 'timeout' commands, using
  strspn(), strchr() and asprintf()
- the latter is in recent POSIX so move _POSIX_C_SOURCE 200809L definition
  within #if HAVE_WORDEXP
- OpenBSD doesn't (and won't) have support for systemd/logind, so only care
  about timeout commands
@emersion
Copy link
Member

Our wordexp usage is indeed an abuse I'd say. We've already removed it from Sway but the patches have not been backported to swaylock/swayidle: https://github.com/swaywm/sway/blob/020a572ed615b8fe272c7566a27ee0abe73a58d7/sway/config.c#L364

Can we just completely get rid of it?

@landryb
Copy link
Author

landryb commented Nov 10, 2023

Our wordexp usage is indeed an abuse I'd say. We've already removed it from Sway but the patches have not been backported to swaylock/swayidle: https://github.com/swaywm/sway/blob/020a572ed615b8fe272c7566a27ee0abe73a58d7/sway/config.c#L364

Can we just completely get rid of it?

oh definitely ! i see that wordexp() is still used in https://github.com/swaywm/sway/blob/020a572ed615b8fe272c7566a27ee0abe73a58d7/sway/config.c#L659 though, but i'll try to backport/reuse what was done in swaywm/sway@1d62d6bfa at least for the config path lookup, and i can also remove its use from the image path lookup if that's okay with you.

@emersion
Copy link
Member

i see that wordexp() is still used

Yeah, that one is for include directives and is going to be much more tricky to drop because users do have env variable expansion and shell substitution in their config file (e.g. include $(uname -n)/*).

backports/adapted from swaywm/sway@1d62d6bf

note: as a side effect, env vars can't be used anymore for image paths
@landryb
Copy link
Author

landryb commented Nov 10, 2023

wordexp() usage dropped in 9c065d0 - i'll also backport the config bits to swaywm/swayidle#154, but i wouldnt know for the actual config lines parsing...

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

Successfully merging this pull request may close these issues.

None yet

2 participants