nirish

config files for niri window manager
Log | Files | Refs | README | LICENSE

observers.lua (1550B)


      1 local g = require 'modules.globals'
      2 local directory_movement = require 'modules.navigation.directory-movement'
      3 local fb = require 'modules.apis.fb'
      4 local fb_utils = require 'modules.utils'
      5 local ass = require 'modules.ass'
      6 
      7 ---@class observers
      8 local observers ={}
      9 
     10 ---saves the directory and name of the currently playing file
     11 ---@param _ string
     12 ---@param filepath string
     13 function observers.current_directory(_, filepath)
     14     directory_movement.set_current_file(filepath)
     15 end
     16 
     17 ---@param _ string
     18 ---@param device string
     19 function observers.dvd_device(_, device)
     20     if not device or device == "" then device = '/dev/dvd' end
     21     fb.register_directory_mapping(fb_utils.absolute_path(device), '^dvd://.*', true)
     22 end
     23 
     24 ---@param _ string
     25 ---@param device string
     26 function observers.bd_device(_, device)
     27     if not device or device == '' then device = '/dev/bd' end
     28     fb.register_directory_mapping(fb_utils.absolute_path(device), '^bd://.*', true)
     29 end
     30 
     31 ---@param _ string
     32 ---@param device string
     33 function observers.cd_device(_, device)
     34     if not device or device == '' then device = '/dev/cdrom' end
     35     fb.register_directory_mapping(fb_utils.absolute_path(device), '^cdda://.*', true)
     36 end
     37 
     38 ---@param property string
     39 ---@param alignment string
     40 function observers.osd_align(property, alignment)
     41     if property == 'osd-align-x' then g.ALIGN_X = alignment
     42     elseif property == 'osd-align-y' then g.ALIGN_Y = alignment end
     43 
     44     g.style.global = ([[{\an%d}]]):format(g.ASS_ALIGNMENT_MATRIX[g.ALIGN_Y][g.ALIGN_X])
     45     ass.update_ass()
     46 end
     47 
     48 return observers