Deprecated.
This commit is contained in:
parent
3dfa968e81
commit
2e602549d7
87
exec.sh
87
exec.sh
|
@ -1,87 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#rts/oarion7
|
#rts/oarion7 - ryanthomas.org
|
||||||
|
|
||||||
# See "README" ! Tested with awesome v4.3
|
# Shell layer deprecated
|
||||||
|
|
||||||
script_path="$(dirname "$(realpath "$BASH_SOURCE")")"
|
|
||||||
rofi_theme="${script_path}/invisible.rasi" #key grabber only
|
|
||||||
exit_key='s' # See "README" !
|
|
||||||
hover_time='3' #time to hover in seconds if Ctrl+O
|
|
||||||
hide=true #for hidden systray environment, rehide when escaping/canceling
|
|
||||||
|
|
||||||
deps=( awesome-client iocane rofi xdotool )
|
|
||||||
for i in "${deps[@]}"; do command -v "$i" >/dev/null ||
|
|
||||||
errors=$(printf '%s %s\n' "$errors" "$i" | sed -e 's/^ //'); done
|
|
||||||
[[ "$errors" ]] && { notify-send -u critical \
|
|
||||||
"Veuillez corriger ces dépendances non satisfaites:" "$errors"; exit 1; }
|
|
||||||
|
|
||||||
parse_string() { printf '%s\n' "$1" | awk '{$1=""}1' | sed 's|[ "]||g' ; }
|
|
||||||
# 'string "X"' --> 'X'
|
|
||||||
|
|
||||||
awesome-exec() {
|
|
||||||
local file
|
|
||||||
file="${script_path}/${1}"
|
|
||||||
[ -f "$file" ] && awesome-client 'dofile("'"$file"'")' ||
|
|
||||||
{ echo "Could not find ${1}."; exit 1; }
|
|
||||||
}
|
|
||||||
|
|
||||||
mouse_location() {
|
|
||||||
[[ "$1" == "save" ]] &&
|
|
||||||
{ awesome-client 'sys_hints_saved_coords = mouse.coords({x = x, y = y})'; return; }
|
|
||||||
[[ "$1" == "restore" ]] &&
|
|
||||||
awesome-client 'mouse.coords({x = sys_hints_saved_coords.x, y = sys_hints_saved_coords.y}, true)'
|
|
||||||
}
|
|
||||||
|
|
||||||
hide_systray_hints() { awesome-client 'hide_systray_hints()' >/dev/null ; }
|
|
||||||
|
|
||||||
hide_systray() { awesome-client 'sys_hints_hide_systray()' >/dev/null ; }
|
|
||||||
|
|
||||||
seq_with_exit_key() { (printf '%s\n%s\n' "$exit_key" "$(seq $1)") ; }
|
|
||||||
|
|
||||||
mouse_to_icon() {
|
|
||||||
[[ "$1" == "1" ]] && factor='0' || factor=$(("$1" - 1))
|
|
||||||
target_position_x=$(( $first_icon_x + ( "$icon_width" * "$factor" ) ))
|
|
||||||
iocane -c "${target_position_x},${icons_y}"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_choice() {
|
|
||||||
choice=$(seq_with_exit_key "$icon_count" | rofi \
|
|
||||||
-kb-custom-1 "Ctrl+l" -kb-custom-2 "Ctrl+o" -dmenu -i -theme "$rofi_theme" \
|
|
||||||
-no-custom -auto-select 2>/dev/null )
|
|
||||||
code="$?"
|
|
||||||
}
|
|
||||||
|
|
||||||
awesome-exec "core.lua"
|
|
||||||
data=$(awesome-client "return found_widget_geometry")
|
|
||||||
|
|
||||||
[[ -z "$data" ]] && { echo "Geometery data not found."; exit 1; }
|
|
||||||
|
|
||||||
IFS=',' read -r -a array <<< "$(parse_string "$data")"
|
|
||||||
[[ -n "${array[4]}" ]] || [[ -z "${array[3]}" ]] && { echo "Invalid data: $data"; exit 1; }
|
|
||||||
|
|
||||||
x="${array[0]}" ; y="${array[1]}" ; w="${array[2]}" ; h="${array[3]}"
|
|
||||||
icon_count=$((( $w - ( $w % $h )) / $h + 1 ))
|
|
||||||
icon_width=$(( $w / $icon_count ))
|
|
||||||
half_icon=$(( $icon_width / 2 ))
|
|
||||||
first_icon_x=$(( $x + $half_icon ))
|
|
||||||
icons_y=$(( $y + $half_icon ))
|
|
||||||
|
|
||||||
awesome-client 'systray_show_hints('"${x}, ${y}, ${icon_width}, ${icon_count}"')'
|
|
||||||
|
|
||||||
mouse_location save
|
|
||||||
|
|
||||||
mouse_button='3' #default to right click
|
|
||||||
get_choice; [[ "$code" == "10" ]] && { mouse_button='1'; get_choice; }
|
|
||||||
[[ "$code" == "11" ]] && { unset mouse_button; get_choice; }
|
|
||||||
|
|
||||||
hide_systray_hints
|
|
||||||
|
|
||||||
[[ "$choice" == "$exit_key" ]] && unset choice
|
|
||||||
[[ -z "$choice" ]] && { [[ "$hide" == "true" ]] && hide_systray; exit 0; }
|
|
||||||
|
|
||||||
mouse_to_icon "$choice" &&
|
|
||||||
|
|
||||||
[[ -n "$mouse_button" ]] && xdotool click "$mouse_button"
|
|
||||||
[[ -z "$mouse_button" ]] && sleep "$hover_time" #hover only (not so reliable)
|
|
||||||
|
|
||||||
mouse_location restore
|
|
|
@ -1,40 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Invisible theme to use ROFI as a key grabber
|
*
|
||||||
* Based on a theme by Dave Davenport
|
* Deprecated.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
* {
|
|
||||||
background-color: rgba ( 255, 255, 255, 0 % );
|
|
||||||
border-color: rgba ( 255, 255, 255, 0 % );
|
|
||||||
text-color: rgba ( 255, 255, 255, 0 % );
|
|
||||||
}
|
|
||||||
|
|
||||||
#window {
|
|
||||||
anchor: north;
|
|
||||||
location: north;
|
|
||||||
width: 0;
|
|
||||||
padding: 4px;
|
|
||||||
children: [ horibox ];
|
|
||||||
}
|
|
||||||
|
|
||||||
#horibox {
|
|
||||||
orientation: horizontal;
|
|
||||||
children: [ prompt, entry, listview ];
|
|
||||||
}
|
|
||||||
|
|
||||||
#listview {
|
|
||||||
layout: horizontal;
|
|
||||||
spacing: 5px;
|
|
||||||
lines: 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
#entry {
|
|
||||||
expand: false;
|
|
||||||
width: 10em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#element {
|
|
||||||
padding: 0px 2px;
|
|
||||||
}
|
|
||||||
#element selected {
|
|
||||||
background-color: rgba ( 255, 255, 255, 0 % );
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue