Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


OpenBox Hacks filter_list
Author
Message
OpenBox Hacks #1
Post all yer openbox hacks here Biggrin

My autostart. Basically, what it does is start off crap I can't live without. Guake is AMAZING. You'd have seen it if you've used Blackbuntu.

Code:
cd ~
./.bin/wallpaper.sh &
guake &
conky -d &
tint2 &

My menu.xml. What I'm doing here is do a pipemenu to menu.pl.

Code:
<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://openbox.org/
                file:///usr/share/openbox/menu.xsd">

<menu id="root-menu" label="Rallias" execute="perl ~/.config/openbox/menu.pl" />

</openbox_menu>

My menu.pl (unfinished, can't be assed to finish it tonight). Lots of magic happens in here. So far, it does little personally for me, but the neat thing is if you edit it, you don't need to force the menu to update. Plus, fuck xml.

Code:
#!/usr/bin/perl
# Openbox Configuration Generator
# By Rallias Ubernerd
# Because: Fuck XML

use strict;
use warnings;

#### CONFIGURATION ####
# For each menu and submenu, put appropriate labels as follows
# root must exist, its label is useless and ignored
my %menu_list = (
    'root' => '',
    'programs' => 'Programs'
);
# For each menu, its contents are necessary.
# Syntax: type1:pointsto1;type2:pointsto2;
# Each menu defined above must have one of these.
# Valid types: program, menu, separator, pipemenu
my %menu;
$menu{ 'root' } = "menu:programs;";
$menu{ 'programs' } = "program:Firefox;program:Skype;program:Xchat;";
# For each program defined above, the below must hold their execution command.
# Left side of => is label, right side is the executable command.
my %programs = (
    'Xchat' => 'xchat',
    'Firefox' => 'firefox',
    'Skype' => 'skype'
);
# For each separator defined above, you need a label.
# "blank" as the label makes it a horizontal line across that box.
my %separator_label = (
    'separator' => 'label'
);
# For each item above you can optionally have an image.
# Same syntax as menus above, one item only, no semicolon.
my %icons = (
    'program:Firefox' => '~/.icons/firefox.png'
);

#### EXECUTION ####
my $menu = gen_item_menu("root", 0);
print $menu;

sub gen_item_menu {
    my $curr_menu = shift;
    my $preline = shift;
    
    my $root;
    my $return = "";

    if ($curr_menu =~ m/^root$/) {
        $root = 1;
    } else {
        $root = 0;
    }
    
    if ($root) {
        $return .= "\t" x $preline . qq{<?xml version="1.0" encoding="UTF-8"?>\n};
        $return .= "\t" x $preline . qq{<openbox_pipe_menu>\n};
        $preline += 1;
    } else {
        $return .= "\t" x $preline. qq{<menu id="$curr_menu" label="}.$menu_list{$curr_menu}."\" >\n";
        $preline += 1;
    }

    my @items = split (";", $menu{ $curr_menu });
    foreach my $item (@items) {
        my ($type, $name) = split ":", $item;
        if ($type =~ m/program/ ) {
            $return .= gen_item_program($name, $preline);
        } elsif ($type =~ m/pipemenu/ ) {
            $return .= gen_item_pipe_menu($name, $preline);
        } elsif ($type =~ m/menu/ ) {
            $return .= gen_item_menu($name, $preline);
        } elsif ($type =~ m/seperator/ ) {
            $return .= gen_item_separator($name, $preline);
        } else {
            # Unsupported
        }            
    }

    if ($root) {
        $preline -= 1;
        $return .= "\t" x $preline . qq{</openbox_pipe_menu>\n};
    } else {
        $preline -= 1;
        $return .= "\t" x $preline . qq{</menu>\n};
    }

    return $return;
}

sub gen_item_program {
    my $curr_item = shift;
    my $preline = shift;
    my $return = "";

    if (defined($programs{$curr_item})) {
        $return .= "\t" x $preline . qq{<item label="$curr_item" >\n};
        $return .= "\t" x $preline . qq{\t<action name="Execute">\n};
        $return .= "\t" x $preline . "\t\t".$programs{$curr_item}."\n";
        $return .= "\t" x $preline . "\t</action>\n";
        $return .= "\t" x $preline . "</item>\n";
    } else {
        # Unsupported
    }

    return $return;
}

sub gen_item_pipe_menu {
    # todo: write a pipe-menu line.
}

sub gen_item_separator {
    my $curr_item = shift;
    my $preline = shift;
    my $return = "";
    my $label = $separator_label{$curr_item};

    if ($label =~ m/blank/) {
        $return .= "\t" x $preline . "<separator />\n";
    } elsif ( defined($icons{"seperator:".$label}) ) {
        $return .= "\t" x $preline . qq{<separator label="$label" />\n};
        # todo: add syntax for icon label
    } else {
        $return .= "\t" x $preline . qq{<separator label="$label" />\n};
    }

    return $return;
}

Oh, and the ~/.bin/wallpapers.sh file. Pretty self explanatory.

Code:
#!/bin/bash

while true; do
    find ~/Pictures/Wallpapers -type f \( -name '*.jpg' -o -name '*.jpeg' -o -name '*.png' \) -print0 |
        shuf -n1 -z | xargs -0 feh --bg-scale
    sleep 15s
done

Reply

RE: OpenBox Hacks #2
Lol, I wish I knew more about this. I have no idea what you're talking about..

Reply

RE: OpenBox Hacks #3
Interesting, thanks for this - going to try it out.

Reply







Users browsing this thread: 1 Guest(s)