@@ -52,23 +52,25 @@ class Background {
5252 private static void macosBackgroundFile () {
5353 long interval = Prefs .getBackgroundTimeUnit ().toSeconds (Prefs .getBackgroundInterval ());
5454 //language=XML
55- String plist = "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>" +
56- "<!DOCTYPE plist PUBLIC \" -//Apple//DTD PLIST 1.0//EN\" \" http://www.apple.com/DTDs/PropertyList-1.0.dtd\" >" +
57- "<plist>" +
58- "<dict>" +
59- "<key>Label</key>" +
60- "<string>" + backgroundLabel + "</string>" +
61- "<key>ProgramArguments</key>" +
62- "<array>" +
63- " <string>" + executablePath () + "</string>" +
64- " <string>--background-autosave</string>" +
65- "</array>" +
66- "<key>RunAtLoad</key>" +
67- "<true/>" +
68- "<key>StartInterval</key>" +
69- "<integer>" + interval + "</integer>" +
70- "</dict>" +
71- "</plist>" ;
55+ String plist = STR ."""
56+ <?xml version="1.0" encoding="UTF-8"?>
57+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
58+ <plist>
59+ <dict>
60+ <key>Label</key>
61+ <string>\{backgroundLabel }</string>
62+ <key>ProgramArguments</key>
63+ <array>
64+ <string>\{executablePath ()}</string>
65+ <string>--background-autosave</string>
66+ </array>
67+ <key>RunAtLoad</key>
68+ <true/>
69+ <key>StartInterval</key>
70+ <integer>\{interval }</integer>
71+ </dict>
72+ </plist>
73+ """ ;
7274 try {
7375 Files .createDirectories (plistFilePath .getParent ());
7476 Files .writeString (plistFilePath , plist );
@@ -79,24 +81,24 @@ private static void macosBackgroundFile() {
7981 }
8082
8183 private static void linuxBackgroundFile () {
82- String service = """
84+ String service = STR . """
8385 [Unit]
8486 Description=Save blobs in the background
8587
8688 [Service]
8789 Type=oneshot
88- ExecStart=%s --background-autosave""" . formatted ( executablePath ()) ;
89- String timer = """
90+ ExecStart=\{ executablePath ()} --background-autosave""" ;
91+ String timer = STR . """
9092 [Unit]
9193 Description=Save blobs in the background
9294
9395 [Timer]
9496 OnBootSec=1min
95- OnUnitInactiveSec=%dmin
97+ OnUnitInactiveSec=\{ Prefs . getBackgroundIntervalMinutes ()}min
9698
9799 [Install]
98100 WantedBy=timers.target
99- """ . formatted ( Prefs . getBackgroundIntervalMinutes ()) ;
101+ """ ;
100102 try {
101103 Files .createDirectories (systemdDir );
102104 Files .writeString (systemdDir .resolve ("blobsaver.service" ), service );
@@ -108,34 +110,34 @@ private static void linuxBackgroundFile() {
108110 }
109111
110112 private static Path windowsBackgroundFile () {
111- String xml = """
113+ String xml = STR . """
112114 <?xml version="1.0" encoding="UTF-16"?>
113115 <Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
114116 <RegistrationInfo>
115117 <Author>airsquared</Author>
116118 <Description>Save blobs in the background</Description>
117- <URI>%1$s </URI>
119+ <URI>\{ windowsTaskName } </URI>
118120 </RegistrationInfo>
119121 <Triggers>
120122 <LogonTrigger>
121123 <Repetition>
122- <Interval>PT%2$dM </Interval>
124+ <Interval>PT\{ Prefs . getBackgroundIntervalMinutes ()}M </Interval>
123125 <StopAtDurationEnd>false</StopAtDurationEnd>
124126 </Repetition>
125127 <Enabled>true</Enabled>
126- <UserId>%3$s </UserId>
128+ <UserId>\{ System . getProperty ( "user.name" )} </UserId>
127129 </LogonTrigger>
128130 <RegistrationTrigger>
129131 <Repetition>
130- <Interval>PT%2$dM </Interval>
132+ <Interval>PT\{ Prefs . getBackgroundIntervalMinutes ()}M </Interval>
131133 <StopAtDurationEnd>false</StopAtDurationEnd>
132134 </Repetition>
133135 <Enabled>true</Enabled>
134136 </RegistrationTrigger>
135137 </Triggers>
136138 <Principals>
137139 <Principal id="Author">
138- <UserId>%3$s </UserId>
140+ <UserId>\{ System . getProperty ( "user.name" )} </UserId>
139141 <LogonType>InteractiveToken</LogonType>
140142 <RunLevel>LeastPrivilege</RunLevel>
141143 </Principal>
@@ -163,12 +165,12 @@ private static Path windowsBackgroundFile() {
163165 </Settings>
164166 <Actions Context="Author">
165167 <Exec>
166- <Command>"%4$s "</Command>
168+ <Command>"\{ executablePath ()} "</Command>
167169 <Arguments>--background-autosave</Arguments>
168170 </Exec>
169171 </Actions>
170172 </Task>
171- """ . formatted ( windowsTaskName , Prefs . getBackgroundIntervalMinutes (), System . getProperty ( "user.name" ), executablePath ()) ;
173+ """ ;
172174 try {
173175 Path path = Files .createTempFile ("blobsaver_background_service" , ".xml" );
174176 Files .writeString (path , xml );
0 commit comments