rofi is bae

crash2
Geoffrey Frogeye 2018-08-17 15:34:09 +02:00
parent 6ad14b3231
commit 27a817fff3
10 changed files with 15 additions and 238 deletions

View File

@ -2,7 +2,7 @@
shopt -s nullglob globstar
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | ~/.config/i3/dmenu_cmd -p "Default profile" "$@")
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Default profile" "$@")
[[ -n $profile ]] || exit

View File

@ -2,7 +2,7 @@
shopt -s nullglob globstar
profile=$(echo -e "common\nhorizontal\nvertical\n$(autorandr 2>&1 | cut -d' ' -f1)" | ~/.config/i3/dmenu_cmd -p "Load profile" "$@")
profile=$(echo -e "common\nhorizontal\nvertical\n$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Load profile" "$@")
[[ -n $profile ]] || exit

View File

@ -2,7 +2,7 @@
shopt -s nullglob globstar
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | ~/.config/i3/dmenu_cmd -p "Remove profile" "$@")
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Remove profile" "$@")
[[ -n $profile ]] || exit

View File

@ -2,7 +2,7 @@
shopt -s nullglob globstar
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | ~/.config/i3/dmenu_cmd -p "Save profile" "$@")
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Save profile" "$@")
[[ -n $profile ]] || exit

View File

@ -1,52 +0,0 @@
#!/bin/bash
shopt -s nullglob
# We use this to make sure the cache files are sorted bytewise
LC_COLLATE=C
# Some people copy/paste huge swathes of text that could slow down dmenu
line_length_limit=500
declare -A selections
ordered_selections=()
files=("$HOME/.clipmenu/"*)
# We can't use `for ... in` here because we need to add files to
# ordered_selections from last to first -- that is, newest to oldest. Incoming
# clipboard entries have a ISO datetime prefixed to the front to aid in this.
for (( i=${#files[@]}-1; i>=0; i-- )); do
file=${files[$i]}
# We look for the first line matching regex /./ here because we want the
# first line that can provide reasonable context to the user. That is, if
# you have 5 leading lines of whitespace, displaying " (6 lines)" is much
# less useful than displaying "foo (6 lines)", where "foo" is the first
# line in the entry with actionable context.
first_line=$(sed -n '/./{p;q}' "$file" | cut -c1-"$line_length_limit")
lines=$(wc -l < "$file")
if (( lines > 1 )); then
first_line+=" ($lines lines)"
fi
ordered_selections+=("$first_line")
selections[$first_line]=$file
done
# It's okay to hardcode `-l 8` here as a sensible default without checking
# whether `-l` is also in "$@", because the way that dmenu works allows a later
# argument to override an earlier one. That is, if the user passes in `-l`, our
# one will be ignored.
chosen_line=$(printf '%s\n' "${ordered_selections[@]}" | uniq | $HOME/.config/i3/dmenu_cmd -l 8 -p "Copy" "$@")
[[ $chosen_line ]] || exit 1
for selection in clipboard primary; do
if type -p xsel >/dev/null 2>&1; then
xsel --logfile /dev/null -i --"$selection" < "${selections[$chosen_line]}"
else
xclip -sel "$selection" < "${selections[$chosen_line]}"
fi
done

View File

@ -1,127 +0,0 @@
#!/bin/bash
hr_msg() {
printf -- '\n--- %s ---\n\n' "$1" >&2
}
debug() {
if (( DEBUG )); then
printf '%s\n' "$@" >&2
fi
}
print_debug_info() {
# DEBUG comes from the environment
if ! (( DEBUG )); then
return
fi
local msg="${1?}"
hr_msg "$msg"
hr_msg Environment
env | LC_ALL=C sort >&2
cgroup_path=/proc/$$/cgroup
if [[ -f $cgroup_path ]]; then
hr_msg cgroup
cat "$cgroup_path" >&2
else
hr_msg 'NO CGROUP'
fi
hr_msg 'Finished debug info'
}
print_debug_info 'Initialising'
cache_dir=$HOME/.clipmenu/
# It's ok that this only applies to the final directory.
# shellcheck disable=SC2174
mkdir -p -m0700 "$cache_dir"
declare -A last_data
declare -A last_filename
while sleep "${CLIPMENUD_SLEEP:-0.5}"; do
print_debug_info 'About to run selection'
for selection in clipboard primary; do
print_debug_info "About to do selection for '$selection'"
if type -p xsel >/dev/null 2>&1; then
debug 'Using xsel'
data=$(xsel --logfile /dev/null -o --"$selection"; printf x)
else
debug 'Using xclip'
data=$(xclip -o -sel "$selection"; printf x)
fi
debug "Data before stripping: $data"
# We add and remove the x so that trailing newlines are not stripped.
# Otherwise, they would be stripped by the very nature of how POSIX
# defines command substitution.
data=${data%x}
debug "Data after stripping: $data"
if [[ $data != *[^[:space:]]* ]]; then
debug "Skipping as clipboard is only blank"
continue
fi
if [[ ${last_data[$selection]} == "$data" ]]; then
debug 'Skipping as last selection is the same as this one'
continue
fi
# If we were in the middle of doing a selection when the previous poll
# ran, then we may have got a partial clip.
possible_partial=${last_data[$selection]}
if [[ $possible_partial && $data == "$possible_partial"* ]]; then
debug "$possible_partial is a possible partial of $data"
debug "Removing ${last_filename[$selection]}"
rm -- "${last_filename[$selection]}"
fi
filename="$cache_dir/$(LC_ALL=C date +%F-%T.%N)"
last_data[$selection]=$data
last_filename[$selection]=$filename
debug "Writing $data to $filename"
printf '%s' "$data" > "$filename"
if ! (( NO_OWN_CLIPBOARD )) && [[ $selection != primary ]]; then
# Take ownership of the clipboard, in case the original application
# is unable to serve the clipboard request (due to being suspended,
# etc).
#
# Primary is excluded from the change of ownership as applications
# sometimes act up if clipboard focus is taken away from them --
# for example, urxvt will unhilight text, which is undesirable.
#
# We can't colocate this with the above copying code because
# https://github.com/cdown/clipmenu/issues/34 requires knowing if
# we would skip first.
if type -p xsel >/dev/null 2>&1; then
xsel --logfile /dev/null -o --"$selection" | xsel -i --"$selection"
else
xclip -o -sel "$selection" | xclip -i -sel "$selection"
fi
fi
if ! (( NO_TRANSFER_CLIPBOARD )) && [[ $selection != primary ]]; then
# Copy every clipboard content into primary clipboard
if type -p xsel >/dev/null 2>&1; then
xsel --logfile /dev/null -o --"$selection" | xsel -i --primary
else
xclip -o -sel "$selection" | xclip -i -sel primary
fi
fi
done
done

View File

@ -19,6 +19,11 @@ hide_edge_borders both
#bindsym $mod+y border pixel 2
#bindsym $mod+n border normal
# Compatibility layer for people coming from other backgrounds
bindsym Mod1+Tab exec --no-startup-id rofi -modi window -show window
bindsym Mod1+F2 exec --no-startup-id rofi -modi drun -show drun
bindsym Mod1+F4 kill
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
@ -30,20 +35,16 @@ floating_modifier $mod
# kill focused window
bindsym $mod+z kill
#bindsym Mod1+F4 kill
bindsym button2 kill
# start dmenu (a program launcher)
bindsym $mod+F2 exec --no-startup-id ~/.config/i3/dmenu_run
bindsym Mod1+F2 exec --no-startup-id ~/.config/i3/dmenu_run
bindsym $mod+c exec --no-startup-id ~/.config/i3/passmenu --type
#bindsym $mod+x exec --no-startup-id ~/.config/i3/clipmenu
bindsym $mod+asterisk exec --no-startup-id ~/.config/i3/sshmenu
bindsym $mod+dollar exec --no-startup-id ~/.config/i3/sshmenu root
bindsym $mod+c exec --no-startup-id rofi-pass --last-used
bindsym $mod+asterisk exec --no-startup-id rofi -modi ssh -show ssh
bindsym $mod+dollar exec --no-startup-id rofi -modi ssh -show ssh -ssh-command '{terminal} -e {ssh-client} {host} -t "sudo -s -E"'
bindsym $mod+Tab exec --no-startup-id rofi -modi window -show window
# start program launcher
bindsym $mod+d exec --no-startup-id ~/.config/i3/dmenu_run
bindsym $mod+d exec --no-startup-id rofi -modi run -show run
bindsym $mod+Shift+d exec --no-startup-id rofi -modi drun -show drun
# Start Applications
bindsym $mod+Return exec urxvtc
@ -364,7 +365,6 @@ exec --no-startup-id numlockx on # Activate Num lock
exec --no-startup-id unclutter -root # Hide mouse cursor after some time
#exec --no-startup-id dunst # Notifications (handled by systemd)
exec --no-startup-id keynav # Keyboard cursor controller
#exec --no-startup-id $HOME/.config/i3/clipmenud # Clipboard manager
#exec --no-startup-id mpd # Music Player Daemon (handled by systemd)
exec --no-startup-id ~/.config/i3/ashuffle # MPD Auto-refill
exec --no-startup-id autorandr --change # Screen configuration and everything that depends on it

View File

@ -1,30 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
typeit=0
if [[ $1 == "--type" ]]; then
typeit=1
shift
fi
if PASS=$(which gopass 2> /dev/null); then
password_files="$($PASS ls --flat)"
elif PASS=$(which pass 2> /dev/null); then
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
else
exit
fi
password=$(printf '%s\n' "${password_files[@]}" | $HOME/.config/i3/dmenu_cmd -p "Passwords" "$@")
[[ -n $password ]] || exit
if [[ $typeit -eq 0 ]]; then
$PASS show -c "$password"
else
xdotool - <<<"type --clearmodifiers -- $($PASS show "$password" | head -n 1)"
fi

View File

@ -1,9 +0,0 @@
#!/bin/bash
if [ "$1" == 'root' ]; then
a=" (root)"
b="-t 'sudo -s'"
fi
machine=$(cat ~/.ssh/config | grep '^Host ' | cut -d ' ' -f 2 | grep -v '*' | sort | $HOME/.config/i3/dmenu_cmd -p "SSH$a to ")
if [ ! -z $machine ]; then
urxvtc -e ssh $machine $b
fi

View File

@ -1,5 +0,0 @@
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
echo -e "${password_files[@]}"