You are not logged in.
Hello
I recently got into arch linux and openbox. I have no programming experience so bear with me.
I found a script (wallmenu.py) that lets the user choose a picture file from a set directory, from their openbox pipe menu, and set that picture as the desktop background with "feh --bg-scale" command.
I modified this script a little so that instead thunar would open the files instead of feh, and all files would be read instead of just jpg, png, etc.
On a first trial I set the directory as /home/sunv/Documents. It worked perfectly and I could right-click and view the contents of ~/Documents perfectly, as well as open some documents.
However when I try to set the directory to "/home/sunv", or "/home" or even just "/", the pipemenu does not show anything. It doesn't even show a blank popout menu, which means the script is not working. I tried "/media" and it worked fine.
I am wondering is it just too much information to be processed by the pipe menu, therefore it doesn't work? Or is there something wrong with the script.
Here's the code:
#!/usr/bin/env python
import os
import re
import string
import sys
from os.path import isdir
# --------------------------------------------------------------------------- #
# wallmenu.py #
# version 0.3.0 #
# --------------------------------------------------------------------------- #
# This script creates an openbox pipe menu to choose a file.
# You can configure what types of files are allowed, where to search for
# files, and what program to use to open the images.
# This script will also update a configuration file
# (~/.config/openbox/wallmenurc) that stores the last set wallpaper.
# This means that you can add a line to your .xinitrc file to load the
# last set wallpaper on start-up.
# You can configure this script with the variables below.
# This script will recursively go through directories from the one you
# specify, searching for files.
# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
# Using the config file #
# --------------------------------------------------------------------------- #
# To use the config file that stores the filename of the last set wallpaper,
# you can add a line to your .xinitrc file to load it on start-up. If you
# use Esetroot you can use this example, if not just replace the program
# command with your chosen program:
#
# Esetroot `cat ~/.config/openbox/wallmenurc`
#
# If you want to use this script with feh to set your wallpaper, you don't
# need the script to update a config file. feh automatically inserts the full
# command string used to set the wallpaper into ~/.fehbg. In order to set the
# wallpaper back at the next startof openbox, just add the following to
# ~/.xinitrc:
#
# eval `cat ~/.fehbg`
# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
# User configuration #
# --------------------------------------------------------------------------- #
# types of files accepted (list, seperated by a |)
filetypes = ""
# directory where wallpapers are stored (must be long: no ~ symbol allowed)
directory = "/home/sunv/Documents"
# program to set wallpaper
program = "thunar"
# store wallpaper name in a config file?
config = "no"
# --------------------------------------------------------------------------- #
def genmenu(start, directory):
# get a directory list
dirlist = os.listdir(directory)
for d in dirlist:
# set di to overall directory
di = directory + "/" + d
# if we get a dir, generate a menu
if isdir(di):
print ""
print " <menu id=\"" + di + "\" label=\"" + d + "\" >"
genmenu(start, di)
print " </menu>"
# if we get a file, check if it is a valid type
else:
if re.search(filetypes, string.lower(di)) > 0:
# make fi variable just filename, without extension
fi = string.replace(string.replace(di, directory, ""), "/", "")
fi = fi[:string.rfind(fi, ".")]
# if so, add it to the pipe menu
print " <item label=\"" + fi + "\">"
# execute line to set wallpaper
print " <action name=\"Execute\"><execute>" + program + " \"" + di + "\"</execute></action>"
# if we want to update config file, do so
if config == "yes":
print " <action name=\"Execute\"><execute>~/.config/openbox/wallmenu.py " + di + "</execute></action>"
print " </item>"
def main(argv):
# if we've been passed an argument update the config file with the arg
if len(argv) == 1:
os.system("echo " + argv[0] + " > ~/.config/openbox/wallmenurc")
else:
# start menu
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
print "<openbox_pipe_menu>"
# set the original start directory
start = directory
# generate menu
genmenu(start, directory)
# end menu
print "</openbox_pipe_menu>"
# run the main() function
if __name__ == "__main__":
main(sys.argv[1:])
Offline
check if thunar displays file ie /home/<user>/Documents/<file> I tried it with nautilus and it would only display a whole directory ... xml seems ok... just not sure on the command
MrG
Mr Green
Offline
I think I solved it
I used a script called "dirlist" that runs off perl. Some guy wrote it for pipemenus in openbox.
It works ok, and I can go thru directories and stuff. I think my script wasn't working earlier because the permissions weren't right possibly. For instance I could get into /media but not into /etc.
Offline
Would be nice with a link to the complete script, and a screenshot to see this in action
Unyttig.INFO - Your source to not so useless information
My github - Various configs, dotfiles and nifty scripts
Offline