6 Commits

3 changed files with 56 additions and 8 deletions

View File

@ -13,7 +13,9 @@ An uppercase I looks like a 1, 3 from i3, and 8 because the song [We Are 138](ht
## Requirements ## Requirements
- i3-wm: The i3 window manager.
- acpi: [optional] for battery status. It will still work even without this package, but uses it if it is installed. - acpi: [optional] for battery status. It will still work even without this package, but uses it if it is installed.
- dex: [optional] Alternative method for auto starting applications.
- clipster: clipboard manager - clipster: clipboard manager
- grun: Run application dialog - grun: Run application dialog
- jq: for getting the current workspace - jq: for getting the current workspace

17
i38.sh
View File

@ -10,7 +10,7 @@ i3msg="i3-msg"
export DIALOGOPTS='--no-lines --visit-items' export DIALOGOPTS='--no-lines --visit-items'
# Check to make sure minimum requirements are installed. # Check to make sure minimum requirements are installed.
for i in dialog grun jq sgtk-menu yad ; do for i in dialog jq sgtk-menu yad ; do
if ! command -v "$i" &> /dev/null ; then if ! command -v "$i" &> /dev/null ; then
missing+=("$i") missing+=("$i")
fi fi
@ -156,14 +156,13 @@ done
# Configuration questions # Configuration questions
export i3Mode=$(yesno "Would you like to use ratpoison mode? This behaves more like strychnine, with an escape key followed by keybindings.") export i3Mode=$(yesno "Would you like to use ratpoison mode? This behaves more like strychnine, with an escape key followed by keybindings.")
if [[ $i3Mode -eq 1 ]]; then
mod="Mod4"
fi
# Prevent setting ratpoison mode key to the same as default mode key # Prevent setting ratpoison mode key to the same as default mode key
while [[ "$escapeKey" == "$mod" ]]; do while [[ "$escapeKey" == "$mod" ]]; do
escapeKey="$(menulist "Ratpoison mode key:" Control+t Control+z Control+Escape Alt+Escape Control+Space Super)" if [[ $i3Mode -eq 0 ]]; then
escapeKey="${escapeKey//Alt/Mod1}" escapeKey="$(menulist "Ratpoison mode key:" Control+t Control+z Control+Escape Alt+Escape Control+Space Super)"
escapeKey="${escapeKey//Super/Mod4}" escapeKey="${escapeKey//Alt/Mod1}"
escapeKey="${escapeKey//Super/Mod4}"
fi
mod="$(menulist "I3 mod key, for top level bindings:" Alt Control Super)" mod="$(menulist "I3 mod key, for top level bindings:" Alt Control Super)"
mod="${mod//Alt/Mod1}" mod="${mod//Alt/Mod1}"
mod="${mod//Super/Mod4}" mod="${mod//Super/Mod4}"
@ -275,7 +274,7 @@ focus_follows_mouse no
font pango:monospace 8 font pango:monospace 8
# Run dialog # Run dialog
bindsym \$mod+F2 exec grun bindsym \$mod+F2 exec ${i3Path}/scripts/run_dialog.sh
# Clipboard manager # Clipboard manager
bindsym \$mod+Control+c exec clipster -s bindsym \$mod+Control+c exec clipster -s
@ -419,6 +418,8 @@ bindsym Shift+o exec $(command -v orca) --replace, mode "default"
bindsym Control+semicolon exec bash -c '$i3msg -t run_command reload && spd-say -P important -Cw "I38 Configuration reloaded."', mode "default" bindsym Control+semicolon exec bash -c '$i3msg -t run_command reload && spd-say -P important -Cw "I38 Configuration reloaded."', mode "default"
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) # restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym Control+Shift+semicolon exec bash -c '$i3msg -t run_command restart && spd-say -P important -Cw "I3 restarted."', mode "default" bindsym Control+Shift+semicolon exec bash -c '$i3msg -t run_command restart && spd-say -P important -Cw "I3 restarted."', mode "default"
# Run dialog with exclamation
bindsym Shift+exclam exec ${i3Path}/scripts/run_dialog.sh, mode "default"
# exit i3 (logs you out of your X session) # exit i3 (logs you out of your X session)
bindsym Control+q exec bash -c 'yad --image "dialog-question" --title "I38" --button=yes:0 --button=no:1 --text "You pressed the exit shortcut. Do you really want to exit i3? This will end your X session." && $i3msg -t run_command exit' bindsym Control+q exec bash -c 'yad --image "dialog-question" --title "I38" --button=yes:0 --button=no:1 --text "You pressed the exit shortcut. Do you really want to exit i3? This will end your X session." && $i3msg -t run_command exit'
bindsym Escape mode "default" bindsym Escape mode "default"

45
scripts/run_dialog.sh Executable file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env bash
write_history(){
oldHistory="$(grep -v "$txt" "${historyPath}/.history" | head -n 49)"
echo -e "$txt\n$oldHistory" | sed 's/^$//g' > "${historyPath}/.history"
}
historyPath="$(readlink -f $0)"
historyPath="${historyPath%/*}"
if ! [[ -d "$historyPath" ]]; then
mkdir -p "$historyPath"
fi
if [[ -f "${historyPath}/.history" ]]; then
txt="$(yad --entry --editable --title "I38" --text "Execute program or enter file" --button "Open:0" --separator "\n" --rest "${historyPath}/.history")"
else
txt="$(yad --entry --title "I38" --text "Execute program or enter file" --button "Open:0")"
fi
if [[ -z "$txt" ]]; then
exit 0
fi
if [[ "$txt" =~ ^ftp://|http://|https://|www.* ]]; then
xdg-open $txt
write_history
exit 0
fi
if [[ "$txt" =~ ^mailto://.* ]]; then
xdg-email $txt
write_history
exit 0
fi
if [[ "$txt" =~ ^man://.* ]]; then
eval "${txt/:\/\// }" | yad --text-info --show-cursor --button "Close:0" --title "I38" -
write_history
exit 0
fi
if command -v "$(echo "$txt" | cut -d " " -f1)" &> /dev/null ; then
eval $txt&
else
xdg-open $txt&
fi
write_history
exit 0