nirish

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

setup.lua (1753B)


      1 local mp = require 'mp'
      2 
      3 local o = require 'modules.options'
      4 local g = require 'modules.globals'
      5 local fb_utils = require 'modules.utils'
      6 local fb = require 'modules.apis.fb'
      7 
      8 --sets up the compatible extensions list
      9 local function setup_extensions_list()
     10     --setting up subtitle extensions
     11     for ext in fb_utils.iterate_opt(o.subtitle_extensions:lower(), ',') do
     12         g.sub_extensions[ext] = true
     13         g.extensions[ext] = true
     14     end
     15 
     16     --setting up audio extensions
     17     for ext in fb_utils.iterate_opt(o.audio_extensions:lower(), ',') do
     18         g.audio_extensions[ext] = true
     19         g.extensions[ext] = true
     20     end
     21 
     22     --adding file extensions to the set
     23     for _, ext in ipairs(g.compatible_file_extensions) do
     24         g.extensions[ext] = true
     25     end
     26 
     27     --adding extra extensions on the whitelist
     28     for str in fb_utils.iterate_opt(o.extension_whitelist:lower(), ',') do
     29         g.extensions[str] = true
     30     end
     31 
     32     --removing extensions that are in the blacklist
     33     for str in fb_utils.iterate_opt(o.extension_blacklist:lower(), ',') do
     34         g.extensions[str] = nil
     35     end
     36 end
     37 
     38 --splits the string into a table on the separators
     39 local function setup_root()
     40     for str in fb_utils.iterate_opt(o.root) do
     41         local path = mp.command_native({'expand-path', str}) --[[@as string]]
     42         path = fb_utils.fix_path(path, true)
     43 
     44         local temp = {name = path, type = 'dir', label = str, ass = fb_utils.ass_escape(str, true)}
     45 
     46         g.root[#g.root+1] = temp
     47     end
     48 
     49     if g.PLATFORM == 'windows' then
     50         fb.register_root_item('C:/')
     51     elseif g.PLATFORM ~= nil then
     52         fb.register_root_item('/')
     53     end
     54 end
     55 
     56 ---@class setup
     57 return {
     58     extensions_list = setup_extensions_list,
     59     root = setup_root,
     60 }