if getOperatingSystem()==2 then --linux
  function getCurrentMapsFile()
    local pid=getOpenedProcessID()
    if pid~=0 then
      local r={}
      pcall(function()
        for line in io.lines('/proc/'.. pid ..'/maps') do --reading this another way fails
          table.insert(r,line)
        end
      end)
      return r
    end
  end

  function getProtonInfo()
    --returns the steam compatdata path
    local r=getCurrentMapsFile()
    if r==nil then
      return nil,'No maps file. Likely no process selected'
    end

    local compatdata,protonpath
    for i=1,#r do
      if compatdata==nil then
        local starti,stopi,id = r[i]:find("compatdata/(%d+)")

        if id then
          compatdata=r[i]:sub(r[i]:find("/"),stopi+1)
        end
      end

      if protonpath==nil then
        local p=r[i]:find("/bin/wine") or r[i]:find("/lib/wine")
        if p then
          local s=r[i]:sub(r[i]:find("/"),p-1)
          s=extractFilePath(s)
          if fileExists(s..'proton') then
            protonpath=s
          end
        end
      end

      if protonpath and compatdata then
        return compatdata, protonpath
      end
    end

  end


  function escape(s)
    return s:gsub("([^%w/%._~%-])", "\\%1")
  end

  function launchCEForWindows(pid)
    local cewindowsbin
    local p=fileExists(getCheatEngineDir()..'windowsbin/cheatengine-x86_64.exe')
    if p then
      cewindowsbin=getCheatEngineDir()..'windowsbin/'
    else
      p=fileExists(getCheatEngineDir()..'cheatengine-x86_64.exe')
      if p then
        cewindowsbin=getCheatEngineDir()
      end
    end

    if not p then
      messageDialog('No cheat engine install found in the main or "windowsdir" subdirectory',mtError)
      return
    end


    local compatdata, protonpath=getProtonInfo()
    if protonpath and compatdata then
      local command='STEAM_COMPAT_CLIENT_INSTALL_PATH= STEAM_COMPAT_DATA_PATH='..escape(compatdata)..' '..escape(protonpath)..'proton run '.. escape(cewindowsbin..'cheatengine-x86_64.exe')

      if pid then
        command=command..' --OPENPID '..pid
      end

      shellExecute(command)      
    else
      messageDialog('no proton info found',mtError)
    end
  end

  local oldOnProcessOpened=MainForm.OnProcessOpened
  MainForm.OnProcessOpened=function(...)
    local a,b=getProtonInfo()
    if a and b then
      if messageDialog('The currently opened process looks to be running under Proton. It is recommended to use the windows version of CE inside of this proton environment. Launch the windows version?', mtConfirmation, mbYes, mbNo)==mrYes then
        launchCEForWindows(getOpenedProcessID())
      end
    end

    if oldOnProcessOpened then
      oldOnProcessOpened(...)
    end
  end

  --register an attach callback that when called check if the target process uses proton, and if so, ask to launch the windows version of CE inside of the proton environment
  -- check /proc/pid/cmdline to see if it ends with .exe
  --if so, scan for the proton info (or wine info if no proton)

end

