Add appbuilder and config
This commit is contained in:
parent
2ce4e8b29e
commit
29e03d62c8
171
jwmappbuilder.v
Normal file
171
jwmappbuilder.v
Normal file
@ -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<Dynamic label=\"Applications\" icon=\"view-list\">\n\texec: ${os.args[0]}\n</Dynamic>
|
||||
\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('<?xml version="1.0"?>\n<JWM>')
|
||||
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('</JWM>')
|
||||
}
|
||||
|
||||
fn categorymode(args []bool) {
|
||||
mut linkslist := os.ls('/usr/share/applications/') or { panic(err) }
|
||||
println('<?xml version="1.0"?>\n<JWM>\n<Menu label="Accessories">')
|
||||
//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('</Menu>\n<Menu label="Office">')
|
||||
for mut item in linkslist {
|
||||
if !(item.contains('/IM/')) && checktargetcategory(item, "Office") {
|
||||
println(buildprogram('/usr/share/applications/${item}', args))
|
||||
item = '/IM/'
|
||||
}
|
||||
}
|
||||
println('</Menu>\n<Menu label="Games">')
|
||||
for mut item in linkslist {
|
||||
if !(item.contains('/IM/')) && checktargetcategory(item, "Game") {
|
||||
println(buildprogram('/usr/share/applications/${item}', args))
|
||||
item = '/IM/'
|
||||
}
|
||||
}
|
||||
println('</Menu>\n<Menu label="Graphics">')
|
||||
for mut item in linkslist {
|
||||
if !(item.contains('/IM/')) && checktargetcategory(item, "Graphics") {
|
||||
println(buildprogram('/usr/share/applications/${item}', args))
|
||||
item = '/IM/'
|
||||
}
|
||||
}
|
||||
println('</Menu>\n<Menu label="Internet">')
|
||||
for mut item in linkslist {
|
||||
if !(item.contains('/IM/')) && checktargetcategory(item, "Network") {
|
||||
println(buildprogram('/usr/share/applications/${item}', args))
|
||||
item = '/IM/'
|
||||
}
|
||||
}
|
||||
println('</Menu>\n<Menu label="System Tools">')
|
||||
for mut item in linkslist {
|
||||
if !(item.contains('/IM/')) && checktargetcategory(item, "System") {
|
||||
println(buildprogram('/usr/share/applications/${item}', args))
|
||||
item = '/IM/'
|
||||
}
|
||||
}
|
||||
println('</Menu>\n<Menu label="Other">')
|
||||
for mut item in linkslist {
|
||||
if !(item.contains('/IM/')) {
|
||||
println(buildprogram('/usr/share/applications/${item}', args))
|
||||
}
|
||||
}
|
||||
println('</Menu>\n</JWM>')
|
||||
}
|
||||
|
||||
fn buildprogram(filename string, args []bool) string {
|
||||
//println("Opening")
|
||||
file := os.read_file(filename) or {
|
||||
panic(err)
|
||||
}
|
||||
content := file.split_into_lines()
|
||||
return '<Program ${optbuildicon(content, args[0])} label="${strfinder(content, 1)}" ${optbuildtooltip(content, args[1])}>${strfinder(content, 2)}</Program>'
|
||||
}
|
||||
|
||||
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)}"')
|
||||
}
|
237
system.jwmrc
Normal file
237
system.jwmrc
Normal file
@ -0,0 +1,237 @@
|
||||
<?xml version="1.0"?>
|
||||
<JWM>
|
||||
<StartupCommand>setxkbmap -model pc105 -layout us,ru -option grp:alt_shift_toggle</StartupCommand>
|
||||
<StartupCommand>flameshot</StartupCommand>
|
||||
<StartupCommand>nitrogen --restore</StartupCommand>
|
||||
<StartupCommand>/home/nikopol/Bin/Powertunnel/startpw.sh</StartupCommand>
|
||||
<StartupCommand>nm-applet</StartupCommand>
|
||||
<StartupCommand>pasystray</StartupCommand>
|
||||
<StartupCommand>blueman-manager</StartupCommand>
|
||||
|
||||
<!-- The root menu. -->
|
||||
<RootMenu onroot="12">
|
||||
<Program icon="utilities-terminal" label="Terminal" tooltip="Terminal emulator for CLI programs.">terminator</Program>
|
||||
<Program label="Files" icon="folder">pcmanfm</Program>
|
||||
<Dynamic label="Applications" icon="view-list">exec: ~/jwmappbuilderlive -i -t</Dynamic>
|
||||
<!--<Menu icon="folder" label="Utilities">
|
||||
<Program icon="font" label="Fonts">xfontsel</Program>
|
||||
<Program icon="info" label="Window Properties">
|
||||
xprop | xmessage -file -
|
||||
</Program>
|
||||
<Program icon="info" label="Window Information">
|
||||
xwininfo | xmessage -file -
|
||||
</Program>
|
||||
</Menu>
|
||||
<Separator/>
|
||||
<Program icon="lock" label="Lock">
|
||||
xscreensaver-command -lock
|
||||
</Program>-->
|
||||
<Separator/>
|
||||
<Menu icon="document-open-recent" label="Session...">
|
||||
<Restart label="Reload JWM" icon="view-refresh"/>
|
||||
<Program label="Reload Wallpapers" icon="view-refresh">nitrogen --restore</Program>
|
||||
<Exit label="Log out" confirm="true" icon="exit"/>
|
||||
</Menu>
|
||||
<Menu icon="view-more" label="Power...">
|
||||
<Program icon="view-refresh" label="Restart">reboot</Program>
|
||||
<Program icon="system-shutdown" label="Power Off">poweroff</Program>
|
||||
</Menu>
|
||||
</RootMenu>
|
||||
|
||||
<!-- Options for program groups. -->
|
||||
<Group>
|
||||
<Option>tiled</Option>
|
||||
</Group>
|
||||
<Group>
|
||||
<Name>xterm</Name>
|
||||
<Option>vmax</Option>
|
||||
</Group>
|
||||
<Group>
|
||||
<Name>xclock</Name>
|
||||
<Option>drag</Option>
|
||||
<Option>notitle</Option>
|
||||
</Group>
|
||||
|
||||
<!-- Tray at the bottom. -->
|
||||
<Tray x="0" y="-1" autohide="off" delay="1000" height="50">
|
||||
|
||||
<TrayButton label="Start">root:1</TrayButton>
|
||||
<Spacer width="5"/>
|
||||
<!--<Pager labeled="true"/>-->
|
||||
<TaskList maxwidth="256" labeled="false"/>
|
||||
<!--<Swallow width="32" height="32" name="xclock">xclock</Swallow>-->
|
||||
<Dock/>
|
||||
<Clock format="%H:%M"><Button mask="123">exec:xclock</Button></Clock>
|
||||
<TrayButton label="_">showdesktop</TrayButton>
|
||||
|
||||
</Tray>
|
||||
|
||||
<!-- Visual Styles -->
|
||||
<WindowStyle decorations="flat">
|
||||
<Font>Wix Madefor Display-18:weight=bold</Font>
|
||||
<Width>1</Width>
|
||||
<Corner>0</Corner>
|
||||
<Foreground>#FFFFFF</Foreground>
|
||||
<Background>#555555</Background>
|
||||
<Opacity>0.5</Opacity>
|
||||
<Active>
|
||||
<Foreground>#FFFFFF</Foreground>
|
||||
<Background>#0077CC</Background>
|
||||
<Opacity>1.0</Opacity>
|
||||
</Active>
|
||||
</WindowStyle>
|
||||
<TrayStyle decorations="flat">
|
||||
|
||||
<Font>Wix Madefor Display-16</Font>
|
||||
<Background>#333333</Background>
|
||||
<Foreground>#FFFFFF</Foreground>
|
||||
<Opacity>0.75</Opacity>
|
||||
</TrayStyle>
|
||||
<TaskListStyle list="all" group="false" showkill="true">
|
||||
<Font>Wix Madefor Display-16</Font>
|
||||
<Active>
|
||||
<Foreground>#FFFFFF</Foreground>
|
||||
<Background>#555555</Background>
|
||||
</Active>
|
||||
<Foreground>#FFFFFF</Foreground>
|
||||
<Background>#333333</Background>
|
||||
</TaskListStyle>
|
||||
<PagerStyle>
|
||||
<Foreground>#555555</Foreground>
|
||||
<Background>#333333</Background>
|
||||
<Text>#FFFFFF</Text>
|
||||
<Active>
|
||||
<Foreground>#0077CC</Foreground>
|
||||
<Background>#004488</Background>
|
||||
</Active>
|
||||
</PagerStyle>
|
||||
<MenuStyle decorations="flat">
|
||||
<Font>Wix Madefor Display-18</Font>
|
||||
<Foreground>#FFFFFF</Foreground>
|
||||
<Background>#333333</Background>
|
||||
<Active>
|
||||
<Foreground>#FFFFFF</Foreground>
|
||||
<Background>#0077CC</Background>
|
||||
</Active>
|
||||
<Opacity>0.85</Opacity>
|
||||
</MenuStyle>
|
||||
<PopupStyle>
|
||||
<Font>Wix Madefor Display-16</Font>
|
||||
<Foreground>#000000</Foreground>
|
||||
<Background>#999999</Background>
|
||||
</PopupStyle>
|
||||
|
||||
<!-- Path where icons can be found.
|
||||
IconPath can be listed multiple times to allow searching
|
||||
for icons in multiple paths.
|
||||
-->
|
||||
<IconPath>
|
||||
/usr/share/icons/Papirus-Dark/24x24/actions
|
||||
</IconPath>
|
||||
<IconPath>
|
||||
/usr/share/icons/Papirus-Dark/24x24/apps
|
||||
</IconPath>
|
||||
<IconPath>
|
||||
/usr/share/icons/Papirus-Dark/24x24/places
|
||||
</IconPath>
|
||||
<IconPath>
|
||||
/usr/share/icons/Papirus-Dark/24x24/status
|
||||
</IconPath>
|
||||
<IconPath>
|
||||
/usr/share/icons/Papirus-Dark/24x24/mimetypes
|
||||
</IconPath>
|
||||
<IconPath>
|
||||
/usr/share/jwm
|
||||
</IconPath>
|
||||
|
||||
<!-- Virtual Desktops -->
|
||||
<!-- Desktop tags can be contained within Desktops for desktop names. -->
|
||||
<Desktops width="1" height="1">
|
||||
<!-- Default background. Note that a Background tag can be
|
||||
contained within a Desktop tag to give a specific background
|
||||
for that desktop.
|
||||
-->
|
||||
<Background type="solid">#111111</Background>
|
||||
</Desktops>
|
||||
|
||||
<!-- Double click speed (in milliseconds) -->
|
||||
<DoubleClickSpeed>400</DoubleClickSpeed>
|
||||
|
||||
<!-- Double click delta (in pixels) -->
|
||||
<DoubleClickDelta>2</DoubleClickDelta>
|
||||
|
||||
<!-- The focus model (sloppy or click) -->
|
||||
<FocusModel>click</FocusModel>
|
||||
|
||||
<!-- The snap mode (none, screen, or border) -->
|
||||
<SnapMode distance="10">border</SnapMode>
|
||||
|
||||
<!-- The move mode (outline or opaque) -->
|
||||
<MoveMode>opaque</MoveMode>
|
||||
|
||||
<!-- The resize mode (outline or opaque) -->
|
||||
<ResizeMode>opaque</ResizeMode>
|
||||
|
||||
<!-- Key bindings -->
|
||||
<Key key="Up">up</Key>
|
||||
<Key key="Down">down</Key>
|
||||
<Key key="Right">right</Key>
|
||||
<Key key="Left">left</Key>
|
||||
<Key key="h">left</Key>
|
||||
<Key key="j">down</Key>
|
||||
<Key key="k">up</Key>
|
||||
<Key key="l">right</Key>
|
||||
<Key key="Return">select</Key>
|
||||
<Key key="Escape">escape</Key>
|
||||
|
||||
<Key keycode="107">exec: flameshot gui -c</Key>
|
||||
<Key keycode="133">exec: flameshot screen -c</Key>
|
||||
<Key keycode="121">exec: pactl set-sink-mute @DEFAULT_SINK@ toggle</Key>
|
||||
<Key keycode="122">exec: pactl set-sink-volume @DEFAULT_SINK@ -2%</Key>
|
||||
<Key keycode="123">exec: pactl set-sink-volume @DEFAULT_SINK@ +2%</Key>
|
||||
|
||||
<Key mask="A" key="Tab">nextstacked</Key>
|
||||
<Key mask="A" key="F4">close</Key>
|
||||
<Key mask="A" key="#">desktop#</Key>
|
||||
<Key mask="A" key="F1">root:1</Key>
|
||||
<Key mask="A" key="F2">window</Key>
|
||||
<Key mask="A" key="F10">maximize</Key>
|
||||
<Key mask="A" key="Right">rdesktop</Key>
|
||||
<Key mask="A" key="Left">ldesktop</Key>
|
||||
<Key mask="A" key="Up">udesktop</Key>
|
||||
<Key mask="A" key="Down">ddesktop</Key>
|
||||
|
||||
<!-- Mouse bindings -->
|
||||
<Mouse context="root" button="4">ldesktop</Mouse>
|
||||
<Mouse context="root" button="5">rdesktop</Mouse>
|
||||
|
||||
<Mouse context="title" button="1">move</Mouse>
|
||||
<Mouse context="title" button="2">move</Mouse>
|
||||
<Mouse context="title" button="3">window</Mouse>
|
||||
<Mouse context="title" button="4">shade</Mouse>
|
||||
<Mouse context="title" button="5">shade</Mouse>
|
||||
<Mouse context="title" button="11">maximize</Mouse>
|
||||
|
||||
<Mouse context="icon" button="1">window</Mouse>
|
||||
<Mouse context="icon" button="2">move</Mouse>
|
||||
<Mouse context="icon" button="3">window</Mouse>
|
||||
<Mouse context="icon" button="4">shade</Mouse>
|
||||
<Mouse context="icon" button="5">shade</Mouse>
|
||||
|
||||
<Mouse context="border" button="1">resize</Mouse>
|
||||
<Mouse context="border" button="2">move</Mouse>
|
||||
<Mouse context="border" button="3">window</Mouse>
|
||||
|
||||
<Mouse context="close" button="-1">close</Mouse>
|
||||
<Mouse context="close" button="2">move</Mouse>
|
||||
<Mouse context="close" button="-3">close</Mouse>
|
||||
|
||||
<Mouse context="maximize" button="-1">maximize</Mouse>
|
||||
<Mouse context="maximize" button="-2">maxv</Mouse>
|
||||
<Mouse context="maximize" button="-3">maxh</Mouse>
|
||||
|
||||
<Mouse context="minimize" button="-1">minimize</Mouse>
|
||||
<Mouse context="minimize" button="2">move</Mouse>
|
||||
<Mouse context="minimize" button="-3">shade</Mouse>
|
||||
|
||||
</JWM>
|
Loading…
Reference in New Issue
Block a user