-
Notifications
You must be signed in to change notification settings - Fork 0
Fix systemd service #30
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
5d593cc
Fixes for plusdeck service
jfhbrook 92598e5
plusdeck systemd policy
jfhbrook 6bc680d
just install-service
jfhbrook f264ab9
Fix file path
jfhbrook cd9667f
Use tomllib
jfhbrook d445878
Connect to system bus
jfhbrook f912fd2
Hacking on policy
jfhbrook 0daa976
Trying some more stuff
jfhbrook 61095f6
This works for root lmao
jfhbrook c104576
Move policy to better folder
jfhbrook afd16f1
Require python-sdbus package
jfhbrook f02e199
Regenerate spec
jfhbrook 8c569f0
Predicting a 4.0 release
jfhbrook c089977
dbus service loads config file based on user
jfhbrook 016ec6a
Update uv.lock
jfhbrook 574fb34
This configuration works for root
jfhbrook 4febc1f
just service-logs
jfhbrook 57f4931
Put the dbus policy in its right place
jfhbrook 0986849
Update CHANGELOG.md
jfhbrook 8202b3f
Update dbus documentation
jfhbrook cd32b52
Nascent script to generate dbus interface docs
jfhbrook af51378
Script to fetch the dbus iface
jfhbrook 442b869
Attempt to configure polkit
jfhbrook 208028a
Separate polkit install from service install
jfhbrook b7637ca
Update to polkit files
jfhbrook 613cab4
Update dbus docs
jfhbrook bce3560
Remove polkit from spec
jfhbrook File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- --> | ||
|
|
||
| <!DOCTYPE busconfig PUBLIC | ||
| "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" | ||
| "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
|
|
||
| <busconfig> | ||
| <!-- Root user can own the plusdeck service --> | ||
| <policy user="root"> | ||
| <allow own="org.jfhbrook.plusdeck"/> | ||
| <allow send_destination="org.jfhbrook.plusdeck"/> | ||
| </policy> | ||
|
|
||
| <!-- Allow access for the "plusdeck" group --> | ||
| <policy group="plusdeck"> | ||
| <allow send_destination="org.jfhbrook.plusdeck"/> | ||
| </policy> | ||
| </busconfig> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| from unittest.mock import Mock | ||
|
|
||
| import click | ||
| from sdbus import sd_bus_open_system, sd_bus_open_user, SdBus | ||
|
|
||
| from plusdeck.cli import async_command, AsyncCommand, echo, LogLevel, OutputMode, STATE | ||
| from plusdeck.client import State | ||
|
|
@@ -27,12 +28,12 @@ class DbusClient(DbusInterface): | |
| A DBus client for the Plus Deck 2C PC Cassette Deck. | ||
| """ | ||
|
|
||
| def __init__(self: Self) -> None: | ||
| def __init__(self: Self, bus: Optional[SdBus] = None) -> None: | ||
| client = Mock(name="client", side_effect=NotImplementedError("client")) | ||
| self.subscribe = Mock(name="client.subscribe") | ||
| super().__init__("", client) | ||
| super().__init__(client) | ||
|
|
||
| cast(Any, self)._proxify(DBUS_NAME, "/") | ||
| cast(Any, self)._proxify(DBUS_NAME, "/", bus=bus) | ||
|
|
||
| async def staged_config(self: Self) -> StagedConfig: | ||
| """ | ||
|
|
@@ -54,6 +55,7 @@ class Obj: | |
| client: DbusClient | ||
| log_level: LogLevel | ||
| output: OutputMode | ||
| user: bool | ||
|
|
||
|
|
||
| def pass_config(fn: AsyncCommand) -> AsyncCommand: | ||
|
|
@@ -146,11 +148,12 @@ def warn_dirty() -> None: | |
| default="text", | ||
| help="Output either human-friendly text or JSON", | ||
| ) | ||
| @click.option( | ||
| "--user/--no-user", type=bool, default=False, help="Connect to the user bus" | ||
| ) | ||
| @click.pass_context | ||
| def main( | ||
| ctx: click.Context, | ||
| log_level: LogLevel, | ||
| output: OutputMode, | ||
| ctx: click.Context, log_level: LogLevel, output: OutputMode, user: bool | ||
| ) -> None: | ||
| """ | ||
| Control your Plus Deck 2C Cassette Drive through dbus. | ||
|
|
@@ -162,8 +165,9 @@ def main( | |
| echo.mode = output | ||
|
|
||
| async def load() -> None: | ||
| client = DbusClient() | ||
| ctx.obj = Obj(client=client, log_level=log_level, output=output) | ||
| bus: SdBus = sd_bus_open_user() if user else sd_bus_open_system() | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figured out that the default bus is the system bus when started with a non-user systemd unit: https://www.freedesktop.org/software/systemd/man/latest/sd_bus_default.html based on me being able to get past a "where is the bus tho" error, I seem to understand this correctly. |
||
| client = DbusClient(bus) | ||
| ctx.obj = Obj(client=client, log_level=log_level, output=output, user=user) | ||
|
|
||
| asyncio.run(load()) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.