#!/bin/sh
#
###
if ! [ -f "$HOME/.dmenurc" ]; then
	cp /usr/share/dmenu/dmenurc $HOME/.dmenurc
fi
. $HOME/.dmenurc

[  $BROWSER && ${BROWSER-x} ] && browser=$BROWSER || browser='midori'
[  $GUI_EDITOR && ${GUI_EDITOR-x} ] && gui_editor=$GUI_EDITOR || gui_editor='gedit'

eval $(xdotool getmouselocation --shell)
menu_widht=200
monitor_widht=$(wattr w $(lsw -r))
monitor_height=$(wattr h $(lsw -r))
lines=14
menu_height=$(( $lines * 23 ))
maxx=$(( $monitor_widht - $menu_widht ))
miny=$PANEL_HEIGHT
maxy=$(( $monitor_height - $menu_height ))
XP=$X
[ $XP -gt $maxx ] && XP=$maxx
YP=$Y
[ $YP -lt $miny ] && YP=$miny
[ $YP -gt $maxy ] && YP=$maxy

rofi -config "~/.config/rofi/config-monocle.rasi" -theme-str "#window { location: northwest; border: 0; width: 350; x-offset: ${XP}px; y-offset: ${YP}px;}" -show drun -display-drun 'Run ->'
