Skip to content

Commit 0e55c4b

Browse files
committed
Version 0.4
* Added start on boot option to settings menu * Allowed the files in the /opt/ directory to be managed by the package manager * Cleaned a bit of the code * Updated readme instructions
1 parent ff27c22 commit 0e55c4b

10 files changed

Lines changed: 72 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A fairly simple GTK tool built to mimic the basic functionality of ThrottleStop
44

55
Uses <a href="https://github.com/kitsunyan/intel-undervolt">intel-undervolt</a> to perform the undervolting, therefore it must be installed on the user's system. <a href="https://github.com/kitsunyan/intel-undervolt/blob/master/README.md">The guide to installing it can be found here</a>
66

7-
To run this program, download the deb file from the latest <a href="https://github.com/TheOneMaster/linux-undervolt/releases/latest">release</a> and install it to the user's system. Once installed, it can be run either using the command line call `linux_undervolt` or finding the application in the application launcher (Currently it uses a placeholder icon from gnome).
7+
To run this program, download the deb file from the latest <a href="https://github.com/TheOneMaster/linux-undervolt/releases/latest">release</a> and install it to the user's system. Once installed, it can be run either using the command line call `linux-undervolt` or finding the application in the application launcher (Currently it uses a placeholder icon from gnome).
88

99
## GUI Instructions
1010

linux_undervolt/GUI.glade

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@
124124
<property name="use-underline">True</property>
125125
</object>
126126
</child>
127+
<child>
128+
<object class="GtkCheckMenuItem" id="startup_menu_item">
129+
<property name="visible">True</property>
130+
<property name="can-focus">False</property>
131+
<property name="label" translatable="yes">Start on Boot</property>
132+
<property name="use-underline">True</property>
133+
<property name="draw-as-radio">True</property>
134+
<signal name="toggled" handler="startupChange" swapped="no"/>
135+
</object>
136+
</child>
127137
</object>
128138
</child>
129139
</object>
@@ -788,6 +798,9 @@
788798
<property name="position">1</property>
789799
</packing>
790800
</child>
801+
<style>
802+
<class name="inset-box"/>
803+
</style>
791804
</object>
792805
<packing>
793806
<property name="left-attach">1</property>

linux_undervolt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3-2"
1+
__version__ = "0.4-1"

linux_undervolt/__main__.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ def __init__(self):
4949
self.builder.connect_signals(self)
5050

5151
# Initial setup
52-
self.scaleChange()
53-
self.powerSwitch()
54-
self.getPowerProfiles()
52+
self.__initialSetup__()
5553

5654
Notify.init("Linux Undervolt Tool")
5755

@@ -100,7 +98,18 @@ def firstTimeSetup(self) -> gtk.ResponseType:
10098
# UI Changes #
10199
##############
102100

103-
def scaleChange(self):
101+
def __initialSetup__(self):
102+
"""
103+
Initial UI Settings to be loaded when the app is starting. Reads config options from config file
104+
and applies them to the various widgets.
105+
"""
106+
107+
self.__scaleChange__()
108+
self.__getPowerProfiles__()
109+
self.__powerSwitch__()
110+
self.__startupMenuItem__()
111+
112+
def __scaleChange__(self):
104113
"""
105114
Changes the scale values to the current profile values.
106115
"""
@@ -119,7 +128,7 @@ def scaleChange(self):
119128
save_button = self.builder.get_object("save_button")
120129
save_button.set_label("Save")
121130

122-
def getPowerProfiles(self):
131+
def __getPowerProfiles__(self):
123132
"""
124133
Change power profile dropdowns to settings value.
125134
"""
@@ -145,7 +154,7 @@ def getPowerProfiles(self):
145154
ac_profile_dropdown.set_active(ac_profile)
146155
ac_profile_check.set_active(True)
147156

148-
def powerSwitch(self):
157+
def __powerSwitch__(self):
149158
"""
150159
Activate or deactivate the power profile options according to settings.
151160
"""
@@ -160,6 +169,13 @@ def powerSwitch(self):
160169
cur_obj = self.builder.get_object(object)
161170
cur_obj.set_sensitive(active)
162171

172+
def __startupMenuItem__(self):
173+
174+
active = self.config._parser.getboolean('SETTINGS', 'startup')
175+
item = self.builder.get_object("startup_menu_item")
176+
177+
item.set_active(active)
178+
163179
def onSliderChange(self, widget):
164180
"""
165181
Changes the save button to be italicised when changes are made to the undervolt values.
@@ -173,6 +189,14 @@ def onSliderChange(self, widget):
173189
# Config Functions #
174190
####################
175191

192+
def startupChange(self, widget):
193+
194+
startup_value = 1 if widget.get_active() else 0
195+
196+
self.config.changeSettings('startup', str(startup_value))
197+
backend.startupChange(startup_value)
198+
199+
176200
def powerProfileActivate(self, _, state):
177201
"""
178202
docstring
@@ -188,7 +212,7 @@ def powerProfileActivate(self, _, state):
188212
return
189213

190214
self.config.changeSettings('battery_switch', state_str)
191-
self.powerSwitch()
215+
self.__powerSwitch__()
192216

193217
def changeProfile(self, widget):
194218
"""
@@ -204,7 +228,7 @@ def changeProfile(self, widget):
204228
self.config.changeSettings('profile', new_profile)
205229
break
206230

207-
self.scaleChange()
231+
self.__scaleChange__()
208232

209233
def setPowerProfile(self, _):
210234
"""

linux_undervolt/backend.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,17 @@ def createBackup() -> None:
104104
zip_file = os.path.join(CONFIG_DIR, 'intel-undervolt.bak.zip')
105105
with zipfile.ZipFile(zip_file, 'w') as backup_archive:
106106
backup_archive.write(undervolt_file, 'intel-undervolt.conf')
107+
108+
def startupChange(value: int) -> None:
109+
"""
110+
Set the startup behaviour for the undervolt. If on, the undervolt is applied on boot.
111+
Should only be called after the undervolt settings have been tested by the user.
112+
"""
113+
key = {
114+
0: "stop",
115+
1: "start"
116+
}
117+
118+
command = f"pkexec systemctl {key[value]} intel-undervolt"
119+
run = subprocess.run(command, shell=True, stdout=subprocess.DEVNULL)
120+
return run.returncode

linux_undervolt/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def _createConfig(self) -> None:
4242
'undervolt_path': "/etc/intel-undervolt.conf",
4343
'battery_switch': 'false',
4444
'battery_profile': "",
45-
'ac_profile': ""
45+
'ac_profile': "",
46+
'startup': 0
4647
}
4748

4849
profile_options = ['cpu', 'gpu', 'cpu_cache', 'sys_agent', 'analog_io']

linux_undervolt/powersave.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/bin/bash
22

3-
# Copy Python files to opt directory
4-
SCRIPT_PATH=$(dirname $(realpath -s $0))
5-
6-
cp "${SCRIPT_PATH}/config.py" "/opt/linux-undervolt/"
7-
83
# Move temp service to Systemd services
94
mv "${1}/temp.service" "/etc/systemd/system/linux-undervolt.powersave.service"
105
mv "${1}/temp.env" "/etc/systemd/system/linux-undervolt.powersave.env"

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
setup(
9-
name = "linux_undervolt-tool",
9+
name = "linux-undervolt-tool",
1010
version = linux_undervolt.__version__,
1111
author = "TheOneMaster",
1212
author_email = "tmp@gmail.com",
@@ -21,7 +21,8 @@
2121
'gui_scripts': ["linux-undervolt = linux_undervolt.__main__:main"]
2222
},
2323
data_files=[
24-
('share/applications/', ['theonemaster-linux_undervolt.desktop'])
24+
('share/applications/', ['theonemaster-linux_undervolt.desktop']),
25+
('/opt/linux-undervolt', ['linux_undervolt/config.py'])
2526
],
2627
classifiers=[
2728
"License :: OSI Approved :: GPLv2 License"

theonemaster-linux_undervolt.desktop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[Desktop Entry]
22
Name=Linux Undervolt Tool
3-
Version=0.3-2
3+
Version=0.4-1
44
Type=Application
55
Comment=GUI Interface for intel-undervolt
66

7-
Exec=linux_undervolt
7+
Exec=linux-undervolt
88
Icon=/usr/share/icons/gnome/48x48/apps/file-manager.png
99
Categories=Utility;
1010

uninstall.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Remove the Udev rule from the system if it was created.
4+
python3 -c "from linux_undervolt import backend; backend.removeUdevRule()"

0 commit comments

Comments
 (0)