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 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 '
      local ceexe=''
      local param=''

      if pid then
        param=' --OPENPID '..pid
      end
      
      if targetIs64Bit() then
        ceexe='cheatengine-x86_64.exe'
      else
        ceexe='cheatengine-i386.exe'
      end
            
      local p=fileExists(getCheatEngineDir()..'windowsbin/'..ceexe)
      if p then
        cewindowsbin=getCheatEngineDir()..'windowsbin/'
      else
        p=fileExists(getCheatEngineDir()..ceexe)
        if p then  
	        cewindowsbin=getCheatEngineDir()
        end
      end      
      
      if not p then
        messageDialog('No cheat engine for windows install found ('..ceexe..') in the main or "windowsdir" subdirectory',mtError)
        print("use the following command to launch anything in the target process:")
        print(command..'<whatever>')
        return
      end

      command=command..escape(cewindowsbin..ceexe)..param
      
      snap=compatdata:find("snap/steam",0,false)
      if snap then
        --e.g for doom64 on steam snap this works: snap run --shell steam -c "STEAM_COMPAT_CLIENT_INSTALL_PATH=/home/eric/snap/steam/common/.local/share/Steam STEAM_COMPAT_DATA_PATH=/home/eric/snap/steam/common/.local/share/Steam/steamapps/compatdata/1148590 /home/eric/snap/steam/common/.local/share/Steam/steamapps/common/Proton\ -\ Experimental/proton run ./cheatengine-x86_64.exe"
      
      
        command='snap run --shell steam -c "'..command..'"'
      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(executeCode_wine('GetCurrentProcessID'))
      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

