29
29
--- get distribution
30
30
--- @return string
31
31
local function get_distribution ()
32
- local line = io.popen (" lsb_release -i 2>/dev/null" ):read ()
33
- if line == nil then return " linux" end
34
- return line :gsub (" .*:%s*" , " " ):lower ()
32
+ local f = io.open (" /etc/artix-release" )
33
+ if f then
34
+ f :close ()
35
+ return " artix"
36
+ end
37
+ f = io.open (" /etc/os-release" )
38
+ if f == nil then
39
+ f = io.open (" /usr/lib/os-release" )
40
+ end
41
+ if f then
42
+ local result
43
+ for line in f :lines () do
44
+ if line :match (" ^ID=" ) then
45
+ result = line :gsub (" ^ID=" , " " )
46
+ break
47
+ end
48
+ end
49
+ f :close ()
50
+ if result :match (" arch" ) then
51
+ return " arch"
52
+ elseif result :match (" debian" ) then
53
+ return " debian"
54
+ elseif result :match (" raspbian" ) then
55
+ return " raspbian"
56
+ elseif result :match (" ubuntu" ) then
57
+ return " ubuntu"
58
+ elseif result :match (" elementary" ) then
59
+ return " elementary"
60
+ elseif result :match (" fedora" ) then
61
+ return " fedora"
62
+ elseif result :match (" coreos" ) then
63
+ return " coreos"
64
+ elseif result :match (" kali" ) then
65
+ return " kali"
66
+ elseif result :match (" gentoo" ) then
67
+ return " gentoo"
68
+ elseif result :match (" mageia" ) then
69
+ return " mageia"
70
+ elseif result :match (" centos" ) then
71
+ return " centos"
72
+ elseif result :match (" opensuse" ) then
73
+ return " opensuse"
74
+ elseif result :match (" tumbleweed" ) then
75
+ return " opensuse"
76
+ elseif result :match (" sabayon" ) then
77
+ return " sabayon"
78
+ elseif result :match (" slackware" ) then
79
+ return " slackware"
80
+ elseif result :match (" linuxmint" ) then
81
+ return " mint"
82
+ elseif result :match (" alpine" ) then
83
+ return " alpine"
84
+ elseif result :match (" aosc" ) then
85
+ return " aosc"
86
+ elseif result :match (" nixos" ) then
87
+ return " nixos"
88
+ elseif result :match (" devuan" ) then
89
+ return " devuan"
90
+ elseif result :match (" manjaro" ) then
91
+ return " manjaro"
92
+ elseif result :match (" void" ) then
93
+ return " void"
94
+ elseif result :match (" artix" ) then
95
+ return " artix"
96
+ elseif result :match (" rhel" ) then
97
+ return " rhel"
98
+ elseif result :match (" amzn" ) then
99
+ return " amzn"
100
+ elseif result :match (" endeavouros" ) then
101
+ return " endeavouros"
102
+ elseif result :match (" rocky" ) then
103
+ return " rocky"
104
+ elseif result :match (" guix" ) then
105
+ return " guix"
106
+ elseif result :match (" dock" ) then
107
+ return " docker"
108
+ end
109
+ end
110
+ return " linux"
35
111
end
36
112
37
113
--- get os
@@ -40,7 +116,7 @@ local function get_os()
40
116
if os.getenv (" PREFIX" ) == " /data/data/com.termux/files/usr" then
41
117
return " android"
42
118
end
43
- local binary_format = package.cpath :match (' ([^.]+)[;|$] ' )
119
+ local binary_format = package.cpath :match (' ([^.]+)$ ' )
44
120
if binary_format == " so" then
45
121
return get_distribution ()
46
122
elseif binary_format == " dll" then
56
132
local function get_icon ()
57
133
local icons = {
58
134
unknown = " ?" ,
59
- android = " " ,
135
+ alpine = " " ,
136
+ amzn = " " ,
137
+ android = " " ,
138
+ aosc = " " ,
60
139
arch = " " ,
140
+ artix = " " ,
61
141
centos = " " ,
142
+ coreos = " " ,
62
143
debian = " " ,
144
+ devuan = " " ,
63
145
docker = " " ,
146
+ elementary = " " ,
147
+ endeavouros = " " ,
148
+ fedora = " " ,
149
+ freebsd = " " ,
64
150
gentoo = " " ,
65
- linux = " " ,
66
- macos = " " ,
67
- ubuntu = " " ,
151
+ guix = " " ,
152
+ kali = " " ,
153
+ linux = " " ,
154
+ macos = " " ,
155
+ mageia = " " ,
156
+ manjaro = " " ,
157
+ mint = " " ,
68
158
nixos = " " ,
69
- windows = " "
159
+ opensuse = " " ,
160
+ raspbian = " " ,
161
+ rhel = " " ,
162
+ rocky = " " ,
163
+ sabayon = " " ,
164
+ slackware = " " ,
165
+ sunos = " " ,
166
+ ubuntu = " " ,
167
+ void = " " ,
168
+ windows = " " ,
70
169
}
71
170
return icons [get_os ()]
72
171
end
0 commit comments