├── LICENSE ├── Makefile ├── README ├── lib └── x86_64-linux │ ├── tpconfig.compiled │ ├── tpconfig.o │ ├── tpconfig.or │ ├── tpconfig.res │ ├── unit1.lfm │ ├── unit1.o │ └── unit1.ppu ├── tpconfig.lpi ├── tpconfig.lpr ├── tpconfig.lps ├── unit1.lfm └── unit1.pas /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018, thedarkb 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TPConfig: tpconfig.lpr 2 | lazbuild tpconfig.lpr 3 | strip tpconfig 4 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | TPConfig V1.2 is a configuration tool for the ThinkPad TrackPoint. 2 | It requires SystemD and requires Lazarus to build. 3 | It also has to be run as root. 4 | If you'd like to uninstall this, make sure to delete tpconfig.conf from /etc/tmpfiles.d 5 | 6 | This tool is known to work on the R30, X40, X61s, T60, X200, X230, P50, T460s and X250. 7 | -------------------------------------------------------------------------------- /lib/x86_64-linux/tpconfig.compiled: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lib/x86_64-linux/tpconfig.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/tpconfig.o -------------------------------------------------------------------------------- /lib/x86_64-linux/tpconfig.or: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/tpconfig.or -------------------------------------------------------------------------------- /lib/x86_64-linux/tpconfig.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/tpconfig.res -------------------------------------------------------------------------------- /lib/x86_64-linux/unit1.lfm: -------------------------------------------------------------------------------- 1 | object Form1: TForm1 2 | Left = 515 3 | Height = 268 4 | Top = 216 5 | Width = 201 6 | BorderStyle = bsDialog 7 | Caption = 'TPConfig V1.2 ALPHA' 8 | ClientHeight = 268 9 | ClientWidth = 201 10 | OnCreate = FormCreate 11 | LCLVersion = '2.0.2.0' 12 | object speedGroup: TGroupBox 13 | Left = 8 14 | Height = 56 15 | Top = 48 16 | Width = 185 17 | Caption = 'Speed' 18 | ClientHeight = 39 19 | ClientWidth = 181 20 | TabOrder = 0 21 | object speedBar: TTrackBar 22 | Left = 0 23 | Height = 36 24 | Top = 0 25 | Width = 176 26 | Max = 255 27 | Position = 0 28 | TabOrder = 0 29 | end 30 | end 31 | object senseGroup: TGroupBox 32 | Left = 8 33 | Height = 56 34 | Top = 104 35 | Width = 185 36 | Caption = 'Sensitivity' 37 | ClientHeight = 39 38 | ClientWidth = 181 39 | TabOrder = 1 40 | object senseBar: TTrackBar 41 | Left = 0 42 | Height = 36 43 | Top = 0 44 | Width = 176 45 | Max = 255 46 | Position = 0 47 | TabOrder = 0 48 | end 49 | end 50 | object quit: TButton 51 | Left = 8 52 | Height = 25 53 | Top = 240 54 | Width = 88 55 | Caption = 'Quit' 56 | OnClick = quitClick 57 | TabOrder = 2 58 | end 59 | object apply: TButton 60 | Left = 104 61 | Height = 25 62 | Top = 240 63 | Width = 89 64 | Caption = 'Apply' 65 | OnClick = applyClick 66 | TabOrder = 3 67 | end 68 | object pathGroup: TGroupBox 69 | Left = 8 70 | Height = 49 71 | Top = 0 72 | Width = 185 73 | Caption = 'Path' 74 | ClientHeight = 32 75 | ClientWidth = 181 76 | TabOrder = 4 77 | object pathbox: TEdit 78 | Left = 8 79 | Height = 25 80 | Top = 0 81 | Width = 128 82 | Enabled = False 83 | ParentShowHint = False 84 | TabOrder = 0 85 | end 86 | object pathset: TButton 87 | Left = 144 88 | Height = 25 89 | Top = 0 90 | Width = 31 91 | Caption = 'Set' 92 | Enabled = False 93 | OnClick = pathsetClick 94 | TabOrder = 1 95 | end 96 | end 97 | object driftGroup: TGroupBox 98 | Left = 8 99 | Height = 56 100 | Top = 160 101 | Width = 185 102 | Caption = 'Drift Time' 103 | ClientHeight = 39 104 | ClientWidth = 181 105 | TabOrder = 5 106 | object driftBar: TTrackBar 107 | Left = 0 108 | Height = 36 109 | Top = 0 110 | Width = 176 111 | Max = 255 112 | Position = 0 113 | TabOrder = 0 114 | end 115 | end 116 | object setbox: TCheckBox 117 | Left = 8 118 | Height = 22 119 | Top = 216 120 | Width = 180 121 | Caption = 'Enable "Press to Select"' 122 | TabOrder = 6 123 | end 124 | end 125 | -------------------------------------------------------------------------------- /lib/x86_64-linux/unit1.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/unit1.o -------------------------------------------------------------------------------- /lib/x86_64-linux/unit1.ppu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/unit1.ppu -------------------------------------------------------------------------------- /tpconfig.lpi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <ResourceType Value="res"/> 10 | <UseXPManifest Value="True"/> 11 | </General> 12 | <i18n> 13 | <EnableI18N LFM="False"/> 14 | </i18n> 15 | <BuildModes Count="1"> 16 | <Item1 Name="Default" Default="True"/> 17 | </BuildModes> 18 | <PublishOptions> 19 | <Version Value="2"/> 20 | <DestinationDirectory Value="/home/beno/Documents/app/TPconfigetc"/> 21 | </PublishOptions> 22 | <RunParams> 23 | <FormatVersion Value="2"/> 24 | <Modes Count="1"> 25 | <Mode0 Name="default"/> 26 | </Modes> 27 | </RunParams> 28 | <RequiredPackages Count="1"> 29 | <Item1> 30 | <PackageName Value="LCL"/> 31 | </Item1> 32 | </RequiredPackages> 33 | <Units Count="2"> 34 | <Unit0> 35 | <Filename Value="tpconfig.lpr"/> 36 | <IsPartOfProject Value="True"/> 37 | </Unit0> 38 | <Unit1> 39 | <Filename Value="../../unit1.pas"/> 40 | <IsPartOfProject Value="True"/> 41 | <ComponentName Value="Form1"/> 42 | <HasResources Value="True"/> 43 | <ResourceBaseClass Value="Form"/> 44 | <UnitName Value="Unit1"/> 45 | </Unit1> 46 | </Units> 47 | </ProjectOptions> 48 | <CompilerOptions> 49 | <Version Value="11"/> 50 | <Target> 51 | <Filename Value="tpconfig"/> 52 | </Target> 53 | <SearchPaths> 54 | <IncludeFiles Value="$(ProjOutDir)"/> 55 | <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 56 | </SearchPaths> 57 | <Linking> 58 | <Options> 59 | <Win32> 60 | <GraphicApplication Value="True"/> 61 | </Win32> 62 | </Options> 63 | </Linking> 64 | </CompilerOptions> 65 | <Debugging> 66 | <Exceptions Count="4"> 67 | <Item1> 68 | <Name Value="EAbort"/> 69 | </Item1> 70 | <Item2> 71 | <Name Value="ECodetoolError"/> 72 | </Item2> 73 | <Item3> 74 | <Name Value="EFOpenError"/> 75 | </Item3> 76 | <Item4> 77 | <Name Value="EInOutError"/> 78 | </Item4> 79 | </Exceptions> 80 | </Debugging> 81 | </CONFIG> 82 | -------------------------------------------------------------------------------- /tpconfig.lpr: -------------------------------------------------------------------------------- 1 | program tpconfig; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | uses 6 | {$IFDEF UNIX}{$IFDEF UseCThreads} 7 | cthreads, 8 | {$ENDIF}{$ENDIF} 9 | Interfaces, // this includes the LCL widgetset 10 | Forms, Unit1 11 | { you can add units after this }; 12 | 13 | {$R *.res} 14 | 15 | begin 16 | RequireDerivedFormResource:=True; 17 | Application.Initialize; 18 | Application.CreateForm(TForm1, Form1); 19 | Application.Run; 20 | end. 21 | 22 | -------------------------------------------------------------------------------- /tpconfig.lps: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <CONFIG> 3 | <ProjectSession> 4 | <Version Value="11"/> 5 | <BuildModes Active="Default"/> 6 | <Units Count="5"> 7 | <Unit0> 8 | <Filename Value="tpconfig.lpr"/> 9 | <IsPartOfProject Value="True"/> 10 | <EditorIndex Value="2"/> 11 | <CursorPos X="46" Y="12"/> 12 | <UsageCount Value="83"/> 13 | <Loaded Value="True"/> 14 | </Unit0> 15 | <Unit1> 16 | <Filename Value="../../unit1.pas"/> 17 | <IsPartOfProject Value="True"/> 18 | <ComponentName Value="Form1"/> 19 | <HasResources Value="True"/> 20 | <ResourceBaseClass Value="Form"/> 21 | <UnitName Value="Unit1"/> 22 | <EditorIndex Value="-1"/> 23 | <WindowIndex Value="-1"/> 24 | <TopLine Value="112"/> 25 | <CursorPos Y="53"/> 26 | <UsageCount Value="83"/> 27 | </Unit1> 28 | <Unit2> 29 | <Filename Value="tpconfig.lpi"/> 30 | <EditorIndex Value="-1"/> 31 | <UsageCount Value="4"/> 32 | <DefaultSyntaxHighlighter Value="XML"/> 33 | </Unit2> 34 | <Unit3> 35 | <Filename Value="unit1.lfm"/> 36 | <CursorPos X="5" Y="12"/> 37 | <UsageCount Value="39"/> 38 | <Loaded Value="True"/> 39 | <DefaultSyntaxHighlighter Value="LFM"/> 40 | </Unit3> 41 | <Unit4> 42 | <Filename Value="unit1.pas"/> 43 | <ComponentName Value="Form1"/> 44 | <HasResources Value="True"/> 45 | <ResourceBaseClass Value="Form"/> 46 | <UnitName Value="Unit1"/> 47 | <IsVisibleTab Value="True"/> 48 | <EditorIndex Value="1"/> 49 | <TopLine Value="23"/> 50 | <CursorPos X="16" Y="41"/> 51 | <UsageCount Value="41"/> 52 | <Loaded Value="True"/> 53 | <LoadedDesigner Value="True"/> 54 | </Unit4> 55 | </Units> 56 | <JumpHistory Count="24" HistoryIndex="23"> 57 | <Position1> 58 | <Filename Value="unit1.pas"/> 59 | <Caret Line="73" Column="65" TopLine="61"/> 60 | </Position1> 61 | <Position2> 62 | <Filename Value="unit1.pas"/> 63 | <Caret Line="74" Column="65" TopLine="62"/> 64 | </Position2> 65 | <Position3> 66 | <Filename Value="unit1.pas"/> 67 | <Caret Line="73" Column="65" TopLine="61"/> 68 | </Position3> 69 | <Position4> 70 | <Filename Value="unit1.pas"/> 71 | <Caret Line="74" Column="65" TopLine="62"/> 72 | </Position4> 73 | <Position5> 74 | <Filename Value="unit1.pas"/> 75 | <Caret Line="75" Column="65" TopLine="63"/> 76 | </Position5> 77 | <Position6> 78 | <Filename Value="unit1.pas"/> 79 | <Caret Line="79" Column="39" TopLine="64"/> 80 | </Position6> 81 | <Position7> 82 | <Filename Value="unit1.pas"/> 83 | <Caret Line="63" Column="3" TopLine="60"/> 84 | </Position7> 85 | <Position8> 86 | <Filename Value="unit1.pas"/> 87 | <Caret Line="64" Column="3" TopLine="61"/> 88 | </Position8> 89 | <Position9> 90 | <Filename Value="unit1.pas"/> 91 | <Caret Line="63" Column="3" TopLine="60"/> 92 | </Position9> 93 | <Position10> 94 | <Filename Value="unit1.pas"/> 95 | <Caret Line="65" Column="3" TopLine="62"/> 96 | </Position10> 97 | <Position11> 98 | <Filename Value="unit1.pas"/> 99 | <Caret Line="64" Column="3" TopLine="61"/> 100 | </Position11> 101 | <Position12> 102 | <Filename Value="unit1.pas"/> 103 | <Caret Line="63" Column="3" TopLine="61"/> 104 | </Position12> 105 | <Position13> 106 | <Filename Value="unit1.pas"/> 107 | <Caret Line="64" Column="3" TopLine="62"/> 108 | </Position13> 109 | <Position14> 110 | <Filename Value="unit1.pas"/> 111 | <Caret Line="63" Column="3" TopLine="61"/> 112 | </Position14> 113 | <Position15> 114 | <Filename Value="unit1.pas"/> 115 | <Caret Line="65" Column="3" TopLine="63"/> 116 | </Position15> 117 | <Position16> 118 | <Filename Value="unit1.pas"/> 119 | <Caret Line="66" Column="3" TopLine="64"/> 120 | </Position16> 121 | <Position17> 122 | <Filename Value="unit1.pas"/> 123 | <Caret Line="67" Column="3" TopLine="65"/> 124 | </Position17> 125 | <Position18> 126 | <Filename Value="unit1.pas"/> 127 | <Caret Line="66" Column="3" TopLine="64"/> 128 | </Position18> 129 | <Position19> 130 | <Filename Value="unit1.pas"/> 131 | <Caret Line="122" Column="53" TopLine="115"/> 132 | </Position19> 133 | <Position20> 134 | <Filename Value="unit1.pas"/> 135 | <Caret Line="126" Column="26" TopLine="115"/> 136 | </Position20> 137 | <Position21> 138 | <Filename Value="unit1.pas"/> 139 | <Caret Line="88" Column="8" TopLine="72"/> 140 | </Position21> 141 | <Position22> 142 | <Filename Value="unit1.pas"/> 143 | <Caret Line="40" Column="18" TopLine="27"/> 144 | </Position22> 145 | <Position23> 146 | <Filename Value="unit1.pas"/> 147 | <Caret Line="126" Column="15" TopLine="92"/> 148 | </Position23> 149 | <Position24> 150 | <Filename Value="unit1.pas"/> 151 | <Caret Line="177" Column="6" TopLine="162"/> 152 | </Position24> 153 | </JumpHistory> 154 | <RunParams> 155 | <FormatVersion Value="2"/> 156 | <Modes Count="0" ActiveMode="default"/> 157 | </RunParams> 158 | </ProjectSession> 159 | </CONFIG> 160 | -------------------------------------------------------------------------------- /unit1.lfm: -------------------------------------------------------------------------------- 1 | object Form1: TForm1 2 | Left = 515 3 | Height = 268 4 | Top = 216 5 | Width = 201 6 | BorderStyle = bsDialog 7 | Caption = 'TPConfig V1.2' 8 | ClientHeight = 268 9 | ClientWidth = 201 10 | OnCreate = FormCreate 11 | LCLVersion = '2.0.2.0' 12 | object speedGroup: TGroupBox 13 | Left = 8 14 | Height = 56 15 | Top = 48 16 | Width = 185 17 | Caption = 'Speed' 18 | ClientHeight = 39 19 | ClientWidth = 181 20 | TabOrder = 0 21 | object speedBar: TTrackBar 22 | Left = 0 23 | Height = 36 24 | Top = 0 25 | Width = 176 26 | Max = 255 27 | Position = 0 28 | TabOrder = 0 29 | end 30 | end 31 | object senseGroup: TGroupBox 32 | Left = 8 33 | Height = 56 34 | Top = 104 35 | Width = 185 36 | Caption = 'Sensitivity' 37 | ClientHeight = 39 38 | ClientWidth = 181 39 | TabOrder = 1 40 | object senseBar: TTrackBar 41 | Left = 0 42 | Height = 36 43 | Top = 0 44 | Width = 176 45 | Max = 255 46 | Position = 0 47 | TabOrder = 0 48 | end 49 | end 50 | object quit: TButton 51 | Left = 8 52 | Height = 25 53 | Top = 240 54 | Width = 88 55 | Caption = 'Quit' 56 | OnClick = quitClick 57 | TabOrder = 2 58 | end 59 | object apply: TButton 60 | Left = 104 61 | Height = 25 62 | Top = 240 63 | Width = 89 64 | Caption = 'Apply' 65 | OnClick = applyClick 66 | TabOrder = 3 67 | end 68 | object pathGroup: TGroupBox 69 | Left = 8 70 | Height = 49 71 | Top = 0 72 | Width = 185 73 | Caption = 'Path' 74 | ClientHeight = 32 75 | ClientWidth = 181 76 | TabOrder = 4 77 | object pathbox: TEdit 78 | Left = 8 79 | Height = 25 80 | Top = 0 81 | Width = 128 82 | Enabled = False 83 | ParentShowHint = False 84 | TabOrder = 0 85 | end 86 | object pathset: TButton 87 | Left = 144 88 | Height = 25 89 | Top = 0 90 | Width = 31 91 | Caption = 'Set' 92 | Enabled = False 93 | OnClick = pathsetClick 94 | TabOrder = 1 95 | end 96 | end 97 | object driftGroup: TGroupBox 98 | Left = 8 99 | Height = 56 100 | Top = 160 101 | Width = 185 102 | Caption = 'Drift Time' 103 | ClientHeight = 39 104 | ClientWidth = 181 105 | TabOrder = 5 106 | object driftBar: TTrackBar 107 | Left = 0 108 | Height = 36 109 | Top = 0 110 | Width = 176 111 | Max = 255 112 | Position = 0 113 | TabOrder = 0 114 | end 115 | end 116 | object setbox: TCheckBox 117 | Left = 8 118 | Height = 22 119 | Top = 216 120 | Width = 180 121 | Caption = 'Enable "Press to Select"' 122 | TabOrder = 6 123 | end 124 | end 125 | -------------------------------------------------------------------------------- /unit1.pas: -------------------------------------------------------------------------------- 1 | unit Unit1; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 | ComCtrls, Unix, BaseUnix; 10 | 11 | type 12 | 13 | { TForm1 } 14 | 15 | TForm1 = class(TForm) 16 | pathset: TButton; 17 | setbox: TCheckBox; 18 | pathbox: TEdit; 19 | pathGroup: TGroupBox; 20 | quit: TButton; 21 | apply: TButton; 22 | driftBar: TTrackBar; 23 | driftGroup: TGroupBox; 24 | speedGroup: TGroupBox; 25 | senseGroup: TGroupBox; 26 | speedBar: TTrackBar; 27 | senseBar: TTrackBar; 28 | procedure applyClick(Sender: TObject); 29 | procedure FormCreate(Sender: TObject); 30 | procedure pathsetClick(Sender: TObject); 31 | procedure quitClick(Sender: TObject); 32 | private 33 | { private declarations } 34 | public 35 | { public declarations } 36 | end; 37 | 38 | const 39 | conpath = '/etc/tmpfiles.d/tpconfig.conf'; 40 | devpath1 = '/sys/devices/platform/i8042/serio1/serio2/'; //hardcoded paths to devices 41 | devpath2 = '/sys/devices/platform/i8042/serio1/'; //TODO: make less arse 42 | 43 | var 44 | Form1: TForm1; 45 | confH: textfile; 46 | confile: string; 47 | tp: boolean; 48 | workingpath: string; 49 | sysfile: text; 50 | sensitivityt: string; 51 | speedt: string; 52 | driftt: string; 53 | sett: string; 54 | sensitivity: byte; 55 | speed: byte; 56 | drift: byte; 57 | setnum: byte; 58 | setstr: string; 59 | tempfile: text; 60 | user: LongWord; 61 | messagereturn: longint; 62 | assembledStr: string; 63 | checkStr: string; 64 | 65 | implementation 66 | 67 | {$R *.lfm} 68 | 69 | { TForm1 } 70 | 71 | procedure TForm1.FormCreate(Sender: TObject); 72 | begin 73 | fpsystem('touch '+conpath); 74 | tp := false; 75 | if FileExists(devpath1+'sensitivity') then 76 | begin 77 | tp := true; 78 | workingpath := devpath1; 79 | pathbox.Text := workingpath; 80 | end; 81 | if FileExists(devpath2+'sensitivity') then 82 | begin 83 | tp := true; 84 | workingpath := devpath2; 85 | pathbox.Text := workingpath; 86 | end; 87 | if not tp then 88 | begin 89 | messagereturn := Application.MessageBox('No TrackPoint found at the default path, you must specify one.', 'Error'); 90 | apply.Enabled := false; 91 | pathbox.Enabled := true; 92 | pathset.Enabled := true; 93 | end; 94 | if FileExists(conpath) then 95 | begin 96 | user := fpgeteuid; 97 | if not (user=0) then 98 | begin 99 | messagereturn := Application.MessageBox('ERROR: Must be run as root!', 'Fatal Error'); 100 | halt; 101 | end; 102 | if FileExists(workingpath+'sensitivity') then 103 | begin 104 | {check current sensitivity} 105 | AssignFile(sysfile, workingpath+'sensitivity'); 106 | reset(sysfile); 107 | readln(sysfile, sensitivityt); 108 | val(sensitivityt, sensitivity); 109 | senseBar.Position := sensitivity; {initialises the slider with current setting} 110 | 111 | {check current speed} 112 | AssignFile(sysfile, workingpath+'speed'); 113 | reset(sysfile); 114 | readln(sysfile, speedt); 115 | val(speedt, speed); 116 | speedBar.Position := speed; {ditto above} 117 | 118 | {check current drift time} 119 | AssignFile(sysfile, workingpath+'drift_time'); 120 | reset(sysfile); 121 | readln(sysfile, driftt); 122 | val(driftt, drift); 123 | driftBar.Position := drift; {ditto above} 124 | 125 | {check current "press to select" setting} 126 | AssignFile(sysfile, workingpath+'press_to_select'); 127 | reset(sysfile); 128 | readln(sysfile, sett); 129 | val(sett, setnum); 130 | if not setnum = 0 then 131 | begin 132 | setbox.Checked := true; {ditto above, just substitute box for slider} 133 | end; 134 | end; 135 | end; 136 | end; 137 | 138 | procedure TForm1.pathsetClick(Sender: TObject); 139 | begin 140 | checkStr := pathbox.Text; 141 | if FileExists(checkStr+'sensitivity') then 142 | begin 143 | workingpath := checkStr; 144 | apply.Enabled := true; 145 | 146 | {check current sensitivity} 147 | AssignFile(sysfile, workingpath+'sensitivity'); 148 | reset(sysfile); 149 | readln(sysfile, sensitivityt); 150 | val(sensitivityt, sensitivity); 151 | senseBar.Position := sensitivity; {initialises the slider with current setting} 152 | 153 | {check current speed} 154 | AssignFile(sysfile, workingpath+'speed'); 155 | reset(sysfile); 156 | readln(sysfile, speedt); 157 | val(speedt, speed); 158 | speedBar.Position := speed; {ditto above} 159 | 160 | {check current drift time} 161 | AssignFile(sysfile, workingpath+'drift_time'); 162 | reset(sysfile); 163 | readln(sysfile, driftt); 164 | val(driftt, drift); 165 | driftBar.Position := drift; {ditto above} 166 | 167 | {check current "press to select" setting} 168 | AssignFile(sysfile, workingpath+'press_to_select'); 169 | reset(sysfile); 170 | readln(sysfile, sett); 171 | val(sett, setnum); 172 | if not setnum = 0 then 173 | begin 174 | setbox.Checked := true; {ditto above, just substitute box for slider} 175 | end; //I'm well aware that having two of these check blocks is redundant 176 | messagereturn := Application.MessageBox('TrackPoint found at path.', 'Success'); 177 | end; 178 | if not FileExists(workingpath+'sensitivity') then 179 | messagereturn := Application.MessageBox('No TrackPoint found at path.', 'Error'); 180 | end; //I'm just too lazy to put them in a procedure when I can ctrl+c ctrl+v 181 | 182 | procedure TForm1.applyClick(Sender: TObject); 183 | begin 184 | //copies the value on the sliders into bytes for IntToStr later. 185 | sensitivity := senseBar.Position; 186 | speed := speedBar.Position; 187 | drift := driftBar.Position; 188 | setstr := '0'; 189 | if setbox.Checked then 190 | setstr := '1'; 191 | 192 | AssignFile(confH, conpath); 193 | rewrite(confH); 194 | {puts together the lines of the SystemD script which sets the sensitivity 195 | on boot} 196 | assembledStr := 'w '+workingpath+'sensitivity - - - - '+IntToStr(sensitivity); 197 | writeln(confH, assembledStr); 198 | //ditto above but for speed. 199 | assembledStr := 'w '+workingpath+'speed - - - - '+IntToStr(speed); 200 | writeln(confH, assembledStr); 201 | //drift this time 202 | assembledStr := 'w '+workingpath+'drift_time - - - - '+IntToStr(drift); 203 | writeln(confH, assembledStr); 204 | //now for press to select 205 | assembledStr := 'w '+workingpath+'press_to_select - - - - '+setstr; 206 | writeln(confH, assembledStr); 207 | 208 | CloseFile(confH); //closes the script, writing the contents to the disk 209 | fpsystem('systemd-tmpfiles --prefix=/sys --create'); {tells systemD to run the script} 210 | end; 211 | 212 | procedure TForm1.quitClick(Sender: TObject); 213 | begin 214 | {$I-} 215 | halt; 216 | end; 217 | 218 | 219 | end. 220 | 221 | --------------------------------------------------------------------------------