Advertisement
Guest User

Untitled

a guest
Apr 14th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. local _global = {
  2.     utils = require 'mp.utils',
  3.     msg = require 'mp.msg',
  4.     currentFps = "",
  5.     isFs = false
  6. }
  7.  
  8.  
  9. function revertFPS()
  10.     if (_global.isFs == false) then
  11.         return
  12.     end
  13.     setFPS("60")
  14. end
  15.  
  16. function setFPS(value)
  17.     if (value == _global.current_fps) then
  18.         _global.msg.info("FPS is already " .. value)
  19.         return
  20.     end
  21.     _global.current_fps = value
  22.     _global.msg.info("Set FPS to " .. value)
  23.     _global.utils.subprocess({
  24.         ["cancellable"] = false,
  25.         ["args"] = {
  26.             [1] = "nircmdc",
  27.             [2] = "setdisplay",
  28.             [3] = "3840",
  29.             [4] = "2160",
  30.             [5] = "32",
  31.             [6] = value
  32.         }
  33.     })
  34. end
  35.  
  36. function start(name, value)
  37.     _global.msg.verbose("Got fullscreen " .. tostring(value))
  38.     _global.isFs = value
  39.     if (value == true) then
  40.         fps = mp.get_property_native("container-fps")
  41.         _global.msg.verbose("Got FPS " .. tostring(fps))
  42.         if ((24.0 - fps) < 2.0) then
  43.             setFPS("47")
  44.         else
  45.             setFPS("60")
  46.         end
  47.     else
  48.         setFPS("60")
  49.     end
  50. end
  51.  
  52. mp.observe_property("fullscreen", "bool", start)
  53. mp.register_event("shutdown", revertFPS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement