Compare commits

...

1 Commits
1.1 ... main

Author SHA1 Message Date
86e04a1639 Hotfix: Categories were not built at all. 2024-05-16 19:55:20 +04:00

View File

@ -66,7 +66,7 @@ fn allmode(args []bool){
fn buildcategory(args []bool, folder string, item string, catname string, mut linkslist []string) { fn buildcategory(args []bool, folder string, item string, catname string, mut linkslist []string) {
println('<Menu label="${item}">') println('<Menu label="${item}">')
for mut elem in linkslist { for mut elem in linkslist {
if !(elem.contains('/IM/')) && checktargetcategory(elem, item) { if !(elem.contains('/IM/')) && checktargetcategory(elem, catname) {
println(buildprogram('${folder}${elem}', args)) println(buildprogram('${folder}${elem}', args))
elem = '/IM/' elem = '/IM/'
} }
@ -76,18 +76,18 @@ fn buildcategory(args []bool, folder string, item string, catname string, mut li
fn categorymode(args []bool) { fn categorymode(args []bool) {
mut linkslist := os.ls('/usr/share/applications/') or { panic(err) } mut linkslist := os.ls('/usr/share/applications/') or { panic(err) }
println('<?xml version="1.0"?>\n<JWM>\n<Menu label="Accessories">') println('<?xml version="1.0"?>\n<JWM>')
//Clean up trash //Clean up trash
for mut item in linkslist { for mut item in linkslist {
if !(item.contains('.desktop')) || item.contains('krita_') { item = '/IM/' } if !(item.contains('.desktop')) || item.contains('krita_') { item = '/IM/' }
} }
buildcategory(args, '/usr/share/applications/', "Utility", "Accessories", mut linkslist) buildcategory(args, '/usr/share/applications/', "Accessories", "Utility", mut linkslist)
buildcategory(args, '/usr/share/applications/', "Office", "Office", mut linkslist) buildcategory(args, '/usr/share/applications/', "Office", "Office", mut linkslist)
buildcategory(args, '/usr/share/applications/', "Game", "Games", mut linkslist) buildcategory(args, '/usr/share/applications/', "Games", "Game", mut linkslist)
buildcategory(args, '/usr/share/applications/', "Graphics", "Graphics", mut linkslist) buildcategory(args, '/usr/share/applications/', "Graphics", "Graphics", mut linkslist)
buildcategory(args, '/usr/share/applications/', "Network", "Internet", mut linkslist) buildcategory(args, '/usr/share/applications/', "Internet", "Network", mut linkslist)
buildcategory(args, '/usr/share/applications/', "System", "System Tools", mut linkslist) buildcategory(args, '/usr/share/applications/', "System Tools", "System", mut linkslist)
buildcategory(args, '/usr/share/applications/', "Other", "NaN", mut linkslist) buildcategory(args, '/usr/share/applications/', "Other", "NaN", mut linkslist)
println('</JWM>') println('</JWM>')
@ -98,9 +98,7 @@ fn buildprogram(filename string, args []bool) string {
file := os.read_file(filename) or { file := os.read_file(filename) or {
panic(err) panic(err)
} }
content := file.split_into_lines() content := file.split_into_lines()
return '<Program ${optbuildicon(content, args[0])} label="${strfinder(content, 1)}" ${optbuildtooltip(content, args[1])}>${strfinder(content, 2)}</Program>' return '<Program ${optbuildicon(content, args[0])} label="${strfinder(content, 1)}" ${optbuildtooltip(content, args[1])}>${strfinder(content, 2)}</Program>'
} }
@ -149,7 +147,7 @@ fn filter(strorig string, mode int) string {
fn checktargetcategory(filename string, check string) bool { fn checktargetcategory(filename string, check string) bool {
//println("checking") //println("checking")
if filename == "NaN" { if check == "NaN" {
return true return true
} }
for line in (os.read_file("/usr/share/applications/${filename}") or { panic(err) }).split_into_lines() { for line in (os.read_file("/usr/share/applications/${filename}") or { panic(err) }).split_into_lines() {
@ -168,9 +166,9 @@ fn optbuildtooltip(data []string, tooltip bool) string {
return ('tooltip="${strfinder(data, 4)}"') return ('tooltip="${strfinder(data, 4)}"')
} }
fn detectlang() string { /*fn detectlang() string {
for item in (os.read_file('/etc/locale.conf') or { panic(err) }).split_into_lines() { for item in (os.read_file('/etc/locale.conf') or { panic(err) }).split_into_lines() {
if item.contains('LANG=') { return item.substr(5, 10) } if item.contains('LANG=') { return item.substr(5, 10) }
} }
return 'en_US' return 'en_US'
} }*/