Skip to content

Instantly share code, notes, and snippets.

@codec-abc
Created September 28, 2020 07:44
Show Gist options
  • Select an option

  • Save codec-abc/7e58dbea7bb665599ae72d5762f3d456 to your computer and use it in GitHub Desktop.

Select an option

Save codec-abc/7e58dbea7bb665599ae72d5762f3d456 to your computer and use it in GitHub Desktop.
open System.Text
open System.Text.RegularExpressions
let p = new System.Diagnostics.Process()
p.StartInfo.FileName <- "xinput"
p.StartInfo.Arguments <- ("list")
p.StartInfo.RedirectStandardOutput <- true
p.StartInfo.UseShellExecute <- false
p.Start()
let output = p.StandardOutput.ReadToEnd()
let lines = output.Split('\n')
for line in lines do
let r = new Regex(@"id=([0-9]*)", RegexOptions.IgnoreCase)
if line.Contains("Optical Mouse") then
let matches = r.Match(line)
let group = matches.Groups.[1].ToString()
printfn "%s" group
let p = new System.Diagnostics.Process()
p.StartInfo.FileName <- "xinput"
let arg = "set-prop " + group + " \"Device Accel Constant Deceleration\" 3"
printfn "%s" arg
p.StartInfo.Arguments <- (arg)
p.StartInfo.RedirectStandardOutput <- true
p.StartInfo.UseShellExecute <- false
p.Start() |> ignore
printfn "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment