You are not logged in.
Pages: 1
Is there any link to dmenu examples or dmenu scripts.I recently installed awsome and dmenu but I don't know how to configure dmenu...
Offline
I don't have a script available, but this would be a very basic example:
#!/bin/bash
`dmenu < menu.txt`
Dmenu takes a newline-separated list of values on standard input, it then returns on standard output the selected choice. I think I have a post about it on my blog somewhere.
Offline
Thanks I founded on your blog
Offline
I have a nice menu script:
You need to touch ~/.dddmenu, or, if you want, give it a few starting entries too. Then you run it and if you give it a new (unique) command it will add it to .dddmenu
(made for dash, in bash I'm not sure if [ needs to be [[)
#!/bin/dash
newentry=$(dmenu < ~/.dddmenu)
[ -z $newentry ] && exit
[ -z $( (cat ~/.dddmenu; echo $newentry) | sort | uniq -d) ] && echo $newentry >> ~/.dddmenu
exec setsid $newentry
Here is a script for cmus:
Needs the latest git that can do remote searching. You run the script, type in a search command, and it will find the first one and play from there. Goes to view sorted (fix if you want, you can use 1..4)
made for bash (see the difference)
#!/bin/bash
song=$(dmenu < ~/.cmus/search-history)
[[ -n ${song} ]] && echo -e "view sorted\n/${song}\nwin-activate" | cmus-remote
Offline
if you want submenus, tell me. wrote a little script for that
☃ Snowman ☃
Offline
talking of dmenu....
Do you know where are the bookmarks of firefox (location)
so you can launch them directly using dmenu?
Offline
talking of dmenu....
Do you know where are the bookmarks of firefox (location)
so you can launch them directly using dmenu?
~/<USER_NAME>/.mozilla/firefox/<UGLY_FILE_NAME>.default/bookmarks.html
Offline
That's not right, bookmarks are now in a SQL file, places.sqlite. So any bookmarks script is impossible.
Offline
That's not right, bookmarks are now in a SQL file, places.sqlite. So any bookmarks script is impossible.
Holy crapola! I didn't know that it changed. Thanks Procyon.
Offline
For the original question:
RTFW aka Read The Fine Wiki. You will be amazed by all the info you can find on it, so it's a good idea to search first and ask later.
Last edited by Mr.Elendig (2008-09-29 22:29:48)
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
Hey I think that in the about:config of firefox you can tell firefox to "export
your bookmarks every now and than.
Offline
That's not right, bookmarks are now in a SQL file, places.sqlite. So any bookmarks script is impossible.
actually not. you can query and alter sqlite files i.e. using python or with the sqlite3 command (package sqlite3)
cd ~/.mozilla/firefox/YOURPROFILEDIRNAME
cp places.sqlite tmp.sqlite # mozilla locks the DB
sqlite3 tmp.sqlite "SELECT moz_bookmarks.title AS title, moz_places.url AS url
FROM moz_bookmarks INNER JOIN moz_places
ON moz_bookmarks.fk = moz_places.id;"
which will give you a list of
TITLE|URL
(including RSS feeds)
Last edited by robmaloy (2009-04-22 07:32:58)
☃ Snowman ☃
Offline
That is pretty cool, can you also do it so the directory structure is preserved?
Offline
#!/bin/sh
TERMI="urxvt -e sh -c"
CACHE="$HOME/.dmenu_cache_recent"
MOST_USED=`sort $CACHE | uniq -c | sort -rn | colrm 1 8`
RUN=`(echo "$MOST_USED"; dmenu_path | grep -vxF "$MOST_USED") | dmenu "$@"` &&
(echo $RUN; head -n 99 $CACHE) > $CACHE.$$ && mv $CACHE.$$ $CACHE
case $RUN in
*\;) exec $TERMI "$RUN";;
*) exec $RUN;;
esac
Offline
That is pretty cool, can you also do it so the directory structure is preserved?
that should be possible.
i will do some further investigation
edit:
python script to display firefox bookmarks
recursive functions ftw
#!/usr/bin/python
import os
import pysqlite2.dbapi2 as sqlite
import shutil
import ConfigParser
import random
# change this if you want:
DISPLAY_PROFILE_NUMBER = 0
parser = ConfigParser.ConfigParser()
homedir = os.path.expanduser('~')
moz = '.mozilla/firefox'
moz_dir = os.path.join(homedir, moz)
tmpdir = '/tmp'
BOOKMARK = 1
FOLDER = 2
query_folders = 'SELECT id, title FROM moz_bookmarks WHERE type = 2;'
query_bookmarks = 'SELECT moz_bookmarks.id, moz_bookmarks.parent, moz_bookmarks.title, moz_places.url \
FROM moz_bookmarks \
INNER JOIN moz_places \
ON moz_bookmarks.fk = moz_places.id \
WHERE moz_bookmarks.type = 1;'
def getprofiles():
profilesini = os.path.join(moz_dir, 'profiles.ini')
parser.read(profilesini)
prof = []
i = 0
while parser.has_section('Profile' + str(i)):
name = parser.get('Profile' + str(i), 'Name')
path = parser.get('Profile' + str(i), 'Path')
prof.append({'name': name, 'path': path})
i += 1
return prof
def randfilename():
tmp = 'moz_bmarx_'
for i in range(12):
tmp += chr(random.randint(97, 122))
return tmp
def opendb(profile):
places = os.path.join(moz_dir, profile['path'], 'places.sqlite')
tmpfile = os.path.join(tmpdir, randfilename())
shutil.copy(places, tmpfile)
db = sqlite.connect(tmpfile)
return db
def printitem(indent, title, url=''):
'''
strng = indent * '.'
if indent > 0:
strng += '|-- '
'''
strng = indent * '\t'
strng += title + ':'
print(strng.encode('utf-8'))
if (url):
urlstrng = (indent + 1) * '\t' + url
print(urlstrng.encode('utf-8'))
def printtree(db, parent, indent):
cur = db.cursor()
query = 'SELECT id, type FROM moz_bookmarks WHERE parent = ' + str(parent)
cur.execute(query)
res = cur.fetchall()
for item in res:
if item[1] == FOLDER:
query_name = 'SELECT title FROM moz_bookmarks WHERE id = ' + str(item[0])
cur.execute(query_name)
name, = cur.fetchone()
printitem(indent, name)
printtree(db, item[0], indent + 1)
if item[1] == BOOKMARK:
query_bmark = 'SELECT moz_bookmarks.title, moz_places.url \
FROM moz_bookmarks \
INNER JOIN moz_places \
ON moz_bookmarks.fk = moz_places.id \
WHERE moz_bookmarks.id = ' + str(item[0])
cur.execute(query_bmark)
title, url = cur.fetchone()
printitem(indent, title, url)
profs = getprofiles()
prf = profs[DISPLAY_PROFILE_NUMBER]
db = opendb(prf)
print 'Bookmarks from Profile ' + prf['name']
printtree(db, 1, 0)
Last edited by robmaloy (2009-04-24 09:24:56)
☃ Snowman ☃
Offline
@robmaloy: Thanks! I just saw it now.
I have one more request, that is getting all the history, with both URL and title. If it's possible sorted by the last access time.
Offline
I think I got it, I changed your script a bit so it prints all information on one line in 3 columns (directory / title / url). That way you can use dmenu to search for an entry and have firefox launch the URL.
Launcher:
#! /bin/dash
url=$(bookmarkhistory_fx_export | dmenu -i -l 7 -rs -ni -xs | cut -sf3)
[ -z "$url" ] && exit
firefox "$url"
bookmarkhistory_fx_export:
#!/usr/bin/python
import os
import pysqlite2.dbapi2 as sqlite
import shutil
import ConfigParser
import random
import time
# change this if you want:
DISPLAY_PROFILE_NUMBER = 0
parser = ConfigParser.ConfigParser()
homedir = os.path.expanduser('~')
moz = '.mozilla/firefox'
moz_dir = os.path.join(homedir, moz)
tmpdir = '/tmp'
BOOKMARK = 1
FOLDER = 2
query_folders = 'SELECT id, title FROM moz_bookmarks WHERE type = 2;'
query_bookmarks = 'SELECT moz_bookmarks.id, moz_bookmarks.parent, moz_bookmarks.title, moz_places.url \
FROM moz_bookmarks \
INNER JOIN moz_places \
ON moz_bookmarks.fk = moz_places.id \
WHERE moz_bookmarks.type = 1;'
def getprofiles():
profilesini = os.path.join(moz_dir, 'profiles.ini')
parser.read(profilesini)
prof = []
i = 0
while parser.has_section('Profile' + str(i)):
name = parser.get('Profile' + str(i), 'Name')
path = parser.get('Profile' + str(i), 'Path')
prof.append({'name': name, 'path': path})
i += 1
return prof
def randfilename():
tmp = 'moz_bmarx_'
for i in range(12):
tmp += chr(random.randint(97, 122))
return tmp
def opendb(profile):
places = os.path.join(moz_dir, profile['path'], 'places.sqlite')
tmpfile = os.path.join(tmpdir, randfilename())
shutil.copy(places, tmpfile)
db = sqlite.connect(tmpfile)
return db
def printitem(folder, title, url=''):
if not title: title="noname"
if not folder: folder="nofolder"
if not url: url="nourl"
print folder.encode("UTF-8")+"\t"+title.encode("UTF-8")+"\t"+url.encode("UTF-8")
def printtree(db, parent, recentfolder):
cur = db.cursor()
query = 'SELECT id, type FROM moz_bookmarks WHERE parent = ' + str(parent)
cur.execute(query)
res = cur.fetchall()
for item in res:
if item[1] == FOLDER:
query_name = 'SELECT title FROM moz_bookmarks WHERE id = ' + str(item[0])
cur.execute(query_name)
name, = cur.fetchone()
printtree(db, item[0], recentfolder+"/"+name)
if item[1] == BOOKMARK:
query_bmark = 'SELECT moz_bookmarks.title, moz_places.url \
FROM moz_bookmarks \
INNER JOIN moz_places \
ON moz_bookmarks.fk = moz_places.id \
WHERE moz_bookmarks.id = ' + str(item[0])
cur.execute(query_bmark)
title, url = cur.fetchone()
if url[0:5]=="place": continue
printitem(recentfolder, title, url)
def allhistory(db):
cur=db.cursor()
query_history = 'SELECT moz_historyvisits.visit_date, moz_places.title, moz_places.url FROM moz_historyvisits INNER JOIN moz_places ON moz_historyvisits.place_id = moz_places.id ORDER BY moz_historyvisits.visit_date DESC;'
cur.execute(query_history)
res = cur.fetchall()
for item in res:
printitem(time.ctime(item[0]/1000000),item[1],item[2])
profs = getprofiles()
prf = profs[DISPLAY_PROFILE_NUMBER]
db = opendb(prf)
print 'Bookmarks from Profile ' + prf['name']
printtree(db, 1, "")
allhistory(db)
Offline
Pages: 1