taoshi

gpuselect

Jan 25th, 2022 (edited)
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. --gpuselect автор Таоши
  2. --корректно работает при наличии одной клавиатуры в системе
  3. --перекидывает лучшую видеокарту на лучший монитор.
  4. --Подразумевается, что лучший монитор - с клавиатурой
  5.  
  6. local component=require('component')
  7.  
  8. local gpus={}
  9. for addr in component.list('gpu') do gpus[#gpus+1]=addr end
  10.  
  11. local scr={}
  12. for addr in component.list('scree') do scr[#scr+1]=addr end
  13.  
  14. local memory=component.proxy(gpus[1]).totalMemory()
  15. local best=1
  16. for n=1,#gpus do
  17. if memory<component.proxy(gpus[n]).totalMemory() then
  18. memory=component.proxy(gpus[n]).totalMemory()
  19. best=n
  20. end
  21. print(memory,n,component.proxy(gpus[n]).totalMemory())
  22. end
  23.  
  24. bestscr=1
  25. local max_res=0
  26. for n=1,#scr do
  27. component.proxy(gpus[best]).bind(scr[n],true)
  28. if max_res<component.proxy(gpus[best]).maxResolution() then
  29. max_res=component.proxy(gpus[best]).maxResolution()
  30. bestscr=n
  31. end
  32. print('scr='..n..'bestscr='..bestscr)
  33. end
  34. component.proxy(gpus[best]).bind(scr[bestscr],true)
Add Comment
Please, Sign In to add comment