Skip to content

Commit

Permalink
config save operation moved to service
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Oct 23, 2024
1 parent b924780 commit ecc8307
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
6 changes: 1 addition & 5 deletions src/client/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,12 @@ def save_settings(self, a=None, b=None):
data["modes"]["charge_stop_enabled"] = str(self.o("ui_checkbox_battery_treshold").get_active())
# backlight
data["modes"]["powersave_threshold"] = str(self.o("ui_spinbutton_switch_to_performance").get_value())
self.write_settings(data)
fdata = {}
fdata["update"]="client"
fdata["new-config"]=json.dumps(data)
fdata["pid"] = os.getpid()
send_server(fdata)

@asynchronous
def write_settings(self, data):
subprocess.run(["pkexec", actions_file, "save", json.dumps(data)])

###### utility functions ######

def send_notification(self,msg):
Expand Down
21 changes: 0 additions & 21 deletions src/client/actions.py

This file was deleted.

13 changes: 13 additions & 0 deletions src/service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def main(data):
for dev in data["new-backlight"]:
backlight.set_brightness(dev, data["new-backlight"][dev])

if "new-config" in data:
write_settings(json.loads(data["new-config"]))

# client update
udata = {}
udata["mode"] = power.get_mode()
Expand Down Expand Up @@ -76,3 +79,13 @@ def battery_init():
b = battery.battery(dev)
b.set_stop_threshold(get("charge_stop_enabled",False,"modes"))
acpi_battery.append(b)


def write_settings(data):
ctx = ""
for section in data:
ctx += "[" + section + "]\n"
for var in data[section]:
ctx += str(var) + "=" + str(data[section][var]) +"\n"
ctx += "\n"
writefile("/etc/pardus/ppm.conf.d/99-ppm-settings.conf",ctx)

0 comments on commit ecc8307

Please sign in to comment.