You are not logged in.

#1 2010-02-19 12:28:34

Kladiin
Member
Registered: 2010-02-17
Posts: 3

Openbox TODO menu

Hiya,

I've coded an Openbox pipe menu that allows you to put a simple TODO list in your Openbox menu. Items can be added, edited and deleted all through the menu. It's written using shell script and Zenity, and keeps TODOs in a simple flat file in ~/.todo.

EDIT: Uploaded a package to the AUR (I think I did it correctly): http://aur.archlinux.org/packages.php?ID=34809

Here's the code if anyone wants it:

#!/bin/sh
#Todo menu for Openbox
#Copyright (c) 2010 Cameron Turner
#Released under a BSD license

TODO_PATH=~/.config/todo
[ -z "$XDG_CONFIG_HOME" ] || TODO_PATH="$XDG_CONFIG_HOME/todo"

[ ! -f $TODO_PATH ] && touch $TODO_PATH

if [ "$1" = "add" ]
then
  TODO=`zenity --entry --text "Enter todo:" --entry-text ""`
  [ "$TODO" = "" ] && exit
  
  TODO=`echo -n $TODO | sed -e "s/\&/\&/g" -e "s/</\</g" -e "s/>/\>/g"`
  echo $TODO >> $TODO_PATH
elif [ "$1" = "delete" ]
then
  TEMP=`mktemp`
  sed "$2 d" $TODO_PATH > $TEMP
  mv -f $TEMP $TODO_PATH
elif [ "$1" = "edit" ]
then
  TODO=`sed "$2 !d" < $TODO_PATH`
  TODO=`zenity --entry --text "Enter todo:" --entry-text "$TODO"`
  [ "$TODO" = "" ] && exit
  
  TEMP=`mktemp`
  TODO=`echo -n $TODO | sed -e "s/\&/\&/g" -e "s/</\</g" -e "s/>/\>/g"`
  sed "$2 c$TODO" $TODO_PATH > $TEMP
  mv -f $TEMP $TODO_PATH
else
  echo "<openbox_pipe_menu>"
  i=1
  while read LINE
  do
    echo "<menu id=\"todo-$i\" label=\"$LINE\">"
    echo "<item label=\"Edit\">"
    echo "<action name=\"Execute\"><execute>$0 edit $i</execute></action>"
    echo "</item>"
    echo "<item label=\"Delete\">"
    echo "<action name=\"Execute\"><execute>$0 delete $i</execute></action>"
    echo "</item>"
    echo "</menu>"
    i=$(($i+1))
  done < $TODO_PATH
  echo "<separator />"
  echo "<item label=\"Add new todo\">"
  echo "<action name=\"execute\"><execute>$0 add</execute></action>"
  echo "</item>"
  echo "</openbox_pipe_menu>"
fi

(And here's the license:)

Copyright 2010 Cameron Turner. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:

   1. Redistributions of source code must retain the above copyright notice, this list of
      conditions and the following disclaimer.

   2. Redistributions in binary form must reproduce the above copyright notice, this list
      of conditions and the following disclaimer in the documentation and/or other materials
      provided with the distribution.

THIS SOFTWARE IS PROVIDED BY CAMERON TURNER ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CAMERON TURNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of Cameron Turner.

To use, copy this into /usr/bin/openbox-menu or somewhere, make it executable, and add the following line (or similar) into your Openbox root menu:

<menu id="todo-menu" label="TODO" execute="openbox-todo" />

Cheers,
Kladiin

Last edited by Kladiin (2010-02-19 13:54:48)

Offline

#2 2010-02-19 12:53:03

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Openbox TODO menu

Hi Kladiin,

Could you move ~/.todo to $XDG_CONFIG_HOME/todo to avoid clutter in ~? If $XDG_CONFIG_HOME isn't set, use ~/.config/todo by default.

if [ -z "$XDG_CONFIG_HOME" ]; then
  todo_fpath=~/.config/todo
else
  todo_fpath="${XDG_CONFIG_HOME}/todo"
fi

Last edited by Xyne (2010-02-19 16:47:28)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2010-02-19 12:59:58

Kladiin
Member
Registered: 2010-02-17
Posts: 3

Re: Openbox TODO menu

Quickly done, I think that should work. Edited the previous post with the edited code.

Thanks Xyne!

Last edited by Kladiin (2010-02-19 13:00:31)

Offline

Board footer

Powered by FluxBB