diff --git a/jwmappbuilder.v b/jwmappbuilder.v new file mode 100644 index 0000000..6ae829f --- /dev/null +++ b/jwmappbuilder.v @@ -0,0 +1,171 @@ +import os + +fn main() { + mut args := []bool{len: 3} + for mut arg in args { + arg = false + } + for i := 0; i < os.args.len; i++ { + if i == 0 {i++} + match os.args[i] { + "-i", "--icons" { args[0] = true } + "-t", "--tooltip" { args[1] = true } + "-a", "--all" { args[2] = true } + "-h", "--help" { + println("\nUsage:\n ${os.args[0]} [-htia]\n\nGenerates Applications menu for Joe's Window Manager.\n\nUsage in .jwmrc:\n\n\texec: ${os.args[0]}\n + \nOptions:\n -h, --help\tShow this text.\n -i, --icons\tAlso generate icons.\n -t, --tooltip\tAlso generate tooltips.\n -a, --all\tDo not generate categories: list all applications.\n\nv1.0") + exit(0) + } + else { + println("Unknown argument: ${os.args[i]}") + exit(1) + } + } + } + if !args[2] { + categorymode(args) + } else { + allmode(args) + } + +} + +fn allmode(args []bool){ + linkslist := os.ls('/usr/share/applications/') or { panic(err) } + println('\n') + for i:=0; i < linkslist.len-1; i++ { + if linkslist[i].contains('.desktop') && !(linkslist[i].contains('krita_')){ + println(buildprogram('/usr/share/applications/${linkslist[i]}', args)) + + } + } + println('') +} + +fn categorymode(args []bool) { + mut linkslist := os.ls('/usr/share/applications/') or { panic(err) } + println('\n\n') + //Clean up trash + for mut item in linkslist { + if !(item.contains('.desktop')) || item.contains('krita_') { item = '/IM/' } + } + + for mut item in linkslist { + if !(item.contains('/IM/')) && checktargetcategory(item, "Utility") { + println(buildprogram('/usr/share/applications/${item}', args)) + item = '/IM/' + } + } + println('\n') + for mut item in linkslist { + if !(item.contains('/IM/')) && checktargetcategory(item, "Office") { + println(buildprogram('/usr/share/applications/${item}', args)) + item = '/IM/' + } + } + println('\n') + for mut item in linkslist { + if !(item.contains('/IM/')) && checktargetcategory(item, "Game") { + println(buildprogram('/usr/share/applications/${item}', args)) + item = '/IM/' + } + } + println('\n') + for mut item in linkslist { + if !(item.contains('/IM/')) && checktargetcategory(item, "Graphics") { + println(buildprogram('/usr/share/applications/${item}', args)) + item = '/IM/' + } + } + println('\n') + for mut item in linkslist { + if !(item.contains('/IM/')) && checktargetcategory(item, "Network") { + println(buildprogram('/usr/share/applications/${item}', args)) + item = '/IM/' + } + } + println('\n') + for mut item in linkslist { + if !(item.contains('/IM/')) && checktargetcategory(item, "System") { + println(buildprogram('/usr/share/applications/${item}', args)) + item = '/IM/' + } + } + println('\n') + for mut item in linkslist { + if !(item.contains('/IM/')) { + println(buildprogram('/usr/share/applications/${item}', args)) + } + } + println('\n') +} + +fn buildprogram(filename string, args []bool) string { + //println("Opening") + file := os.read_file(filename) or { + panic(err) + } + content := file.split_into_lines() + return '${strfinder(content, 2)}' +} + +fn strfinder(data []string, mode int) string { + for i:=0; i < data.len-1; i++ { + match mode { + 1 { + // Jump to the next line if GenericName= found, we don't need it + if data[i].contains('GenericName=') { i++ } + if data[i].contains('Name=') { return filter(data[i].substr(5, data[i].len), 1) } + } 2 { + // Same as GenericName= + if data[i].contains('TryExec=') { i++ } + if data[i].contains('Exec=') { return filter(data[i].substr(5, data[i].len), 2) } + } 3 { + if data[i].contains('Icon=') { return data[i].substr(5, data[i].len) } + } 4 { + + if data[i].contains('Comment=') { return filter(data[i].substr(8, data[i].len), 2) } + } + else { panic('strfinder: This should NOT happen. Something went REALLY wrong.') } + } + } + return('') +} + +fn filter(strorig string, mode int) string { + mut str := strorig.bytes() + match mode { + 1 { + if strorig.contains('&') { str = strorig.replace('&', 'and').bytes()} + return str.bytestr() + } + 2 { + if strorig.contains('<') { str = strorig.replace('<', '').bytes() } + if str.bytestr().contains('>') { str = str.bytestr().replace('>', '').bytes() } + if str.bytestr().contains(' %u') { str = str.bytestr().replace(' %u', '').bytes() } + if str.bytestr().contains(' %U') { str = str.bytestr().replace(' %U', '').bytes() } + if str.bytestr().contains(' %F') { str = str.bytestr().replace(' %f', '').bytes() } + if str.bytestr().contains(' %F') { str = str.bytestr().replace(' %F', '').bytes() } + return str.bytestr() + } else { panic('filter: This should NOT happen. Something went REALLY wrong.') } + } + return('') +} + +fn checktargetcategory(filename string, check string) bool { + //println("checking") + for line in (os.read_file("/usr/share/applications/${filename}") or { panic(err) }).split_into_lines() { + if line.contains(check) && line.contains("Categories=") { return true } + } + return false +} + +fn optbuildicon(data []string, icons bool) string { + if !icons { return '' } + return ('icon="${strfinder(data, 3)}"') +} + +fn optbuildtooltip(data []string, tooltip bool) string { + if !tooltip { return '' } + return ('tooltip="${strfinder(data, 4)}"') +} diff --git a/system.jwmrc b/system.jwmrc new file mode 100644 index 0000000..0550e8a --- /dev/null +++ b/system.jwmrc @@ -0,0 +1,237 @@ + + + setxkbmap -model pc105 -layout us,ru -option grp:alt_shift_toggle + flameshot + nitrogen --restore + /home/nikopol/Bin/Powertunnel/startpw.sh + nm-applet + pasystray + blueman-manager + + + + terminator + pcmanfm + exec: ~/jwmappbuilderlive -i -t + + + + + nitrogen --restore + + + + reboot + poweroff + + + + + + + + + xterm + + + + xclock + + + + + + + + root:1 + + + + + + + showdesktop + + + + + + Wix Madefor Display-18:weight=bold + 1 + 0 + #FFFFFF + #555555 + 0.5 + + #FFFFFF + #0077CC + 1.0 + + + + + Wix Madefor Display-16 + #333333 + #FFFFFF + 0.75 + + + Wix Madefor Display-16 + + #FFFFFF + #555555 + + #FFFFFF + #333333 + + + #555555 + #333333 + #FFFFFF + + #0077CC + #004488 + + + + Wix Madefor Display-18 + #FFFFFF + #333333 + + #FFFFFF + #0077CC + + 0.85 + + + Wix Madefor Display-16 + #000000 + #999999 + + + + + /usr/share/icons/Papirus-Dark/24x24/actions + + + /usr/share/icons/Papirus-Dark/24x24/apps + + + /usr/share/icons/Papirus-Dark/24x24/places + + + /usr/share/icons/Papirus-Dark/24x24/status + + + /usr/share/icons/Papirus-Dark/24x24/mimetypes + + + /usr/share/jwm + + + + + + + #111111 + + + + 400 + + + 2 + + + click + + + border + + + opaque + + + opaque + + + up + down + right + left + left + down + up + right + select + escape + + exec: flameshot gui -c + exec: flameshot screen -c + exec: pactl set-sink-mute @DEFAULT_SINK@ toggle + exec: pactl set-sink-volume @DEFAULT_SINK@ -2% + exec: pactl set-sink-volume @DEFAULT_SINK@ +2% + + nextstacked + close + desktop# + root:1 + window + maximize + rdesktop + ldesktop + udesktop + ddesktop + + + ldesktop + rdesktop + + move + move + window + shade + shade + maximize + + window + move + window + shade + shade + + resize + move + window + + close + move + close + + maximize + maxv + maxh + + minimize + move + shade + +