diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-19 20:38:29 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-19 20:38:29 -0800 |
| commit | 0793df89e4a018c6abe662181a564ec137b2487a (patch) | |
| tree | ae2bf25c8fbd83d7d16c1ccb73eb7c1e3014ca55 | |
| parent | 18a4fd55833cfa8fad1998b1017aac486ef90115 (diff) | |
| download | mpv-iptv-menu-0793df89e4a018c6abe662181a564ec137b2487a.tar.gz mpv-iptv-menu-0793df89e4a018c6abe662181a564ec137b2487a.tar.xz | |
use tmpfs for bgra images, delete on shutdown
| -rw-r--r-- | config.lua | 1 | ||||
| -rw-r--r-- | main.lua | 4 | ||||
| -rw-r--r-- | osd.lua | 18 |
3 files changed, 21 insertions, 2 deletions
@@ -41,6 +41,7 @@ config.colours = { } local script_dir = mp.get_script_directory() +config.tmp_dir = os.getenv('XDG_RUNTIME_DIR') or '/tmp' config.cache_dir = mp_utils.join_path(script_dir, 'cache') config.img_dir = mp_utils.join_path(script_dir, 'img') config.favourites_file = mp_utils.join_path(script_dir, 'favourites.json') @@ -1355,6 +1355,10 @@ mp.register_event('end-file', function() osd:redraw(state) end) +mp.register_event('shutdown', function() + osd:destroy() +end) + state:push_menu({title = 'mpv-iptv-menu'}) osc_visibility = mp.get_property_native('user-data/osc/visibility', 'auto') @@ -19,6 +19,10 @@ for k, v in pairs(config.colours) do colours[k] = '{\\c&H' .. tag end +local bgra_file = mp_utils.join_path( + config.tmp_dir, + mp.get_script_name() .. '-' .. mp_utils.getpid() .. '.bgra') + local function draw_rect(x1, y1, x2, y2) return string.format( '{\\p1}m %f %f l %f %f %f %f %f %f{\\p0}', @@ -57,6 +61,16 @@ function osd.new(init) return t end +function mt:destroy() + if self.magick_cmd_id then + mp.abort_async_command(self.magick_cmd_id) + end + + if mp_utils.file_info(bgra_file) then + os.remove(bgra_file) + end +end + function mt:dirty() self.is_dirty = true end @@ -256,7 +270,7 @@ function mt:load_img() self.img.min_h, self.img.min_w, self.img.max_h, self.img.max_w), '-print', '%w %h', - 'tmp.bgra' + bgra_file } print('exec: ' .. mp_utils.to_string(magick_cmd)) self.img.magick_cmd = magick_cmd @@ -289,7 +303,7 @@ function mt:load_img() self.img.cmd = { name = 'overlay-add', id = 0, - file = 'tmp.bgra', + file = bgra_file, w = w, h = h, x = self.img.right - w, |
