battery_boost.shell_commands
¶
Wrappers for executing TLP system commands in a Tkinter context.
Provides functions to initialize, toggle, and query TLP using sudo, with error handling suitable for a GUI application.
TlpCommandError
¶
Bases: Exception
Raised when tlp-stat fails to run properly.
Source code in src/battery_boost/shell_commands.py
22 23 | |
initialise_tlp
¶
Initialize TLP to the default state.
Runs sudo tlp start to reset configuration. Shows an error dialog and exits
if the command fails.
Source code in src/battery_boost/shell_commands.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
revoke_permissions
¶
Revoke cached sudo credentials.
Source code in src/battery_boost/shell_commands.py
147 148 149 150 151 152 153 | |
tlp_active
¶
Return True if TLP is installed, enabled, and has run recently.
Source code in src/battery_boost/shell_commands.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
tlp_get_stats
¶
Retrieve TLP battery statistics.
Runs sudo tlp-stat -b and returns stdout.
Raises:
| Type | Description |
|---|---|
TlpCommandError
|
Exception if the command fails. |
Source code in src/battery_boost/shell_commands.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
tlp_running
¶
Return True if TLP is running, else False.
Source code in src/battery_boost/shell_commands.py
133 134 135 136 137 138 139 140 141 142 143 144 | |
tlp_toggle_state
¶
Toggle TLP between default and full-charge profiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_parent
|
App
|
The Tkinter api instance, used for error dialogs. |
required |
current_state
|
BatteryState
|
The current battery profile. |
required |
Returns: True if successful, False otherwise.
Source code in src/battery_boost/shell_commands.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |