Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

User units for the systemd module #294

Open
qaristote opened this issue Jul 19, 2022 · 8 comments
Open

User units for the systemd module #294

qaristote opened this issue Jul 19, 2022 · 8 comments
Labels
feature request module Can affect user bars that use a specific built-in module

Comments

@qaristote
Copy link
Contributor

I'm using barista along with home-manager. home-manager is basically a way to have your home/ directory be generated from configurations files. In particular, you can do things such as programs.emacs = enable and home-manager automatically creates a systemd unit for the Emacs server.

But if i want to access this unit inside barista through the systemd module, I get an error saying the unit is unknown. This is because the unit generated by home-manager is not listed by systemctl list-units, but instead by systemctl --user list-units. I don't know much about systemd but I assume this is because home-manager creates user-specific unit-files but the systemd module in barista can only access root unit-files.

Is there a way to access the units listed only by systemctl --user list-units using barista's systemd module ? If not, could it be extended so that this becomes possible ?

Thanks !

@soumya92
Copy link
Owner

This seems feasible. Right now it connects only to the system dbus, but I expect it should be possible to extend it to support connecting to the current user's dbus as well.

If you want to try making that work go for it, otherwise I might get to it at a less busy time

@soumya92 soumya92 added feature request module Can affect user bars that use a specific built-in module labels Nov 12, 2022
@KarolosLykos
Copy link
Contributor

Hi there! From what I understand, changing the dbusType to session dbus could potentially fix the problem. Including an option to specify the dbusType when creating the module could be a viable solution. Is that correct?

@soumya92
Copy link
Owner

soumya92 commented Apr 6, 2023

That was my expectation, so I think the PR's general logic is sound. Thanks for attempting this!

soumya92 pushed a commit that referenced this issue Apr 6, 2023
Issue: #294 

Added an optional busType parameter in the Service function on the
systemd module in order to not introduce a breaking change.

I tested locally and seems to work just fine
@bavarianbidi
Copy link

As #374 got merged i've decided to give them a try ...

@KarolosLykos (or @soumya92 ) may i ask what OS are you running and how does the systemd.service file has looked during the development?
I'm on ubuntu 22.04 and i tried using a systemd user-config.

I've already have something to see if the docker systemd unit is running fine. This works without any issues
but for some reasons, if i use the same for a UserService i only get the "status" on a first run.
Toggle the user service on/off works fine but i don't get the state updated.

	greenclip := systemd.UserService("greenclip").
		Output(func(si systemd.ServiceInfo) bar.Output {

			out := outputs.Group()
			out.OnClick(click.Left(func() {
				si.Stop()
			}))
			if si.State == systemd.StateActive {
				out.Append(
					outputs.Pango(
						pango.Icon("mdi-clipboard").Color(colors.Hex("#34eb55")),
					))
			} else {
				out.Append(
					outputs.Pango(
						pango.Icon("mdi-clipboard-off").Color(colors.Hex("#eb4034")),
					))
			}

			return out
		})

and the systemd user file (/home/mario/.config/systemd/user/greenclip.service) looks like:

[Unit]
Description=Recycle your clipboard selections with greenclip and don't waste your time anymore to reselect things over and over.

[Service]
ExecStart=/home/mario/bin/greenclip daemon

[Install]
WantedBy=default.target

@soumya92
Copy link
Owner

I don't actually have any user units, so I can't test this. Based on your description my first guess would be that the watcher is actually still watching system bus, so that would be the place to start. If you want to explore go for it, otherwise I'll try to look at this when I have time.

@KarolosLykos
Copy link
Contributor

@bavarianbidi I haven't had extensive experience with the greenclip.service, so I installed it and conducted some debugging. During this process, I observed that there is no event being emitted to the dbus. Additionally, I verified that the watcher is indeed monitoring the session dbus. However, I want to clarify that my knowledge of dbus is somewhat limited, so please take my observations with a grain of salt. I'm using Arch Linux btw with i3wm, and there seem to be some related issues (https://github.com/erebe/greenclip/issues/70) based on my understanding.

@qaristote
Copy link
Contributor Author

This works for me, thanks for implementing this @KarolosLykos ! I do have some dbus watcher problems but for system services as well so I'll open another issue.

@qaristote
Copy link
Contributor Author

I'm having the same issue as #294 (comment) with the emacs server service.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request module Can affect user bars that use a specific built-in module
Projects
None yet
Development

No branches or pull requests

4 participants