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

Systemd service override #19

Closed
Yamakaky opened this issue May 4, 2021 · 2 comments
Closed

Systemd service override #19

Yamakaky opened this issue May 4, 2021 · 2 comments

Comments

@Yamakaky
Copy link

Yamakaky commented May 4, 2021

toggle_clean_bluez overrides the bluetooth.service systemd file in /lib. It would be better to put the ExecStart change in /run/systemd/system/bluetooth.service.d/nxbt.conf. That way, reverting would be done by simply deleting this file. The change would also not survive reboots.

@Yamakaky
Copy link
Author

Yamakaky commented May 4, 2021

As a quick and dirty change, I did the following change which works:

    for i in range(0, len(lines)):
        line = lines[i]
        if line.startswith("ExecStart="):
            # If we want to ensure the plugin is enabled
            if not toggle:
                exec_start = re.sub(" --compat --noplugin=\*", "", line)
            else:
                exec_start = line + " --compat --noplugin=*"

    service = f"[Service]\nExecStart=\n{exec_start}"
    out_file_dir = "/run/systemd/system/bluetooth.service.d/"
    out_file = out_file_dir + "nxbt.conf"
    if toggle:
        os.makedirs(out_file_dir, exist_ok=True)
        with open(out_file, "w") as f:
            f.write(service)
    else:
        os.remove(out_file)

The first part can be cleaned by simply getting the ExecStart from the file, no loop needed.

@Brikwerk
Copy link
Owner

Brikwerk commented Sep 8, 2021

I've accepted your PR to get things rolling with cleaning up the toggle_clean_bluez function. When I find some time, I'll see about prioritizing further cleanup (eg: removing the for loop).

Thanks again for contributing this 👍

@Brikwerk Brikwerk closed this as completed Sep 8, 2021
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

No branches or pull requests

2 participants