[BRLTTY] Modifying systemd units.

Dave Mielke Dave at mielke.cc
Wed Mar 16 16:40:58 EDT 2022


There was a post, recently, showing how to resolve a problem by modifying brltty's path unit. It showed how to do it by directly editing the brtty.path unit file. While it isn't wrong to want to modify a systemd unit file, directly editing that file is the wrong way to do it. For one thing, the next update of that file, perhaps by upgrading the package, will lose the change. So what's the right way?

What you should do is create a unit override file. You do this by first creating the unit's override directory. It has the same name as the unit file, but with .d appended to it. For example, the override directory for brltty.path is brltty.path.d/. Within this directory, you an have as many override files as you wish - just make sure that you give their names the .conf extension.

An override file should begin with the name of the section of the unit that it's overriding, enclosed within [brackets]. For example, if you wish to add configuration to the Service section of the unit, then the override file for that should begin with: [Service]

Below that line, add whatever you want just as you would within the unit file itself. For example, let's suppose you want to define a new environment variable named x, and assign to it the value y. In this case, your override file would look like this:

   [Service]
   Environment=x=y

You can, of course, have as many configuration lines as you wish. You can customize as many sections of the unit as you wish in one file, and you can have as many override files as you wish. If you do it this way then you'll never lose your customizations. And, yes, as was mentioned in the original post, you'll need to execute systemctl daemon-reload in order for your customizations to be picked up.

-- 
I believe the Bible to be the very Word of God: http://Mielke.cc/bible/
Dave Mielke            | 2213 Fox Crescent | WebHome: http://Mielke.cc/
EMail: Dave at Mielke.cc  | Ottawa, Ontario   | Twitter: @Dave_Mielke
Phone: +1 613 726 0014 | Canada  K2A 1H7   |


More information about the BRLTTY mailing list