From 965afb1783949935b99401d18fd640f12e822962 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 22 Nov 2022 21:52:20 -0500 Subject: [PATCH] Saving progress. Will do more later. --- i38.sh | 438 ++++++++++++++++++--------------------------------------- 1 file changed, 133 insertions(+), 305 deletions(-) diff --git a/i38.sh b/i38.sh index df1b3f0..fc6889f 100755 --- a/i38.sh +++ b/i38.sh @@ -9,7 +9,7 @@ i3Path="${XDG_CONFIG_HOME:-$HOME/.config}/i3" export DIALOGOPTS='--no-lines --visit-items' # Check to make sure minimum requirements are installed. -for i in dialog sgtk-menu yad ; do +for i in dialog grun sgtk-menu yad ; do if ! command -v "$i" &> /dev/null ; then missing+=("$i") fi @@ -116,15 +116,6 @@ EOF } -add_setting() -{ -if [ -z "$rc" ]; then -rc="$@" -else -rc="${rc}"$'\n'"$@" -fi -} - # Array of command line arguments declare -A command=( [h]="This help screen." @@ -141,303 +132,140 @@ while getopts "${args}" i ; do esac done - -# Make sure rc variable is empty -unset rc -# Set path for helper scripts. -path="$(readlink -f $0)" -path="${path%/*}" -if ! command -v notify-send &> /dev/null ; then -timeOut="$(rangebox "Seconds for notifications:" 3 10 5)" -notify="yad --info --timeout $timeOut --no-buttons --title 'notification' --text" -else -notify="notify-send" -fi -add_setting "# Generated by strychnine (${0##*/}) https://git.2mb.codes/~stormdragon2976/strychnine"$'\n'"# $(date '+%A, %B %d, %Y at %I:%M%p')"$'\n'$'\n'"# Miscellaneous" -add_setting startup_message off -add_setting set winname title -add_setting "set bgcolor #000000" -add_setting "set fgcolor #FFFFFF" -add_setting 'set font -*-terminus-medium-r-normal-*-24-*-*-*-*-*-*-*' -add_setting set waitcursor 1 -add_setting banish - -# Unbind existing keys that lead to inaccessible things like xterm or keys that user wants to change, or don't make sense for blind users: -add_setting $'\n'"# Unbind section" -add_setting unbind C-A -add_setting unbind A -add_setting unbind C-a -add_setting unbind a -add_setting unbind c -add_setting unbind C-c -add_setting unbind C-f -add_setting unbind F -add_setting unbind r -add_setting unbind C-r -add_setting unbind S -add_setting unbind C-S -add_setting unbind s -add_setting unbind C-s -add_setting unbind C-t -add_setting unbind C-v -add_setting unbind v -add_setting unbind C-w -add_setting unbind C-Down -add_setting unbind Down -add_setting unbind C-exclam -add_setting unbind exclam -add_setting unbind C-Left -add_setting unbind Left -add_setting unbind question -add_setting unbind C-Right -add_setting unbind Right -add_setting unbind C-Up -add_setting unbind Up -add_setting unbind C-apostrophe -add_setting unbind apostrophe -add_setting unbind colon -escapeKey="$(menulist "Ratpoison escape key:" C-t C-z -C-Escape M-Escape C-space Super_L Super_R)" -if [ "$escapeKey" != "C-t" ]; then -add_setting unbind t +# Place holder. Configuration questions go here. +if [[ -d "${i3Path}" ]]; then + yesno "This will replace your existing configuration at ${i3Path}. Do you want to continue?" || exit 0 fi -# Key binding section -add_setting $'\n'"# Key binding section" -# Key binding section -if [ "$escapeKey" != "C-t" ]; then -add_setting escape $escapeKey -fi -add_setting "# Alt+f1 applications menu" -add_setting definekey top M-F1 exec yad --icons --compact --no-buttons --title=\"Ratpoison Applications Menu\" --close-on-unfocus --read-dir=/usr/share/applications -add_setting "# Alt+f2 executes the run dialog" -add_setting definekey top M-F2 run_dialog -add_setting "# Alt+f3 local applications menu" -add_setting definekey top M-F3 exec yad --icons --compact --no-buttons --title=\"Ratpoison Local Applications Menu\" --close-on-unfocus --read-dir=${HOME}/.local/share/applications -add_setting "# Control+Alt+d Desktop" -add_setting definekey top C-M-d exec yad --icons --compact --no-buttons --title=\"Ratpoison Desktop Menu\" --close-on-unfocus --read-dir=${HOME}/Desktop -add_setting "# Alt+tab switches through open windows" -add_setting definekey top M-Tab next -add_setting definekey top M-ISO_Left_Tab prev -add_setting definekey top M-F4 close_window -add_setting "# Media key bindings" -add_setting definekey top XF86AudioPrev music_player_previous_track -add_setting definekey top XF86AudioMute music_player_pause -add_setting definekey top XF86AudioPlay music_player_play -add_setting definekey top XF86AudioStop music_player_stop -add_setting definekey top XF86AudioNext music_player_next_track -add_setting definekey top XF86AudioLowerVolume music_player_decrease_volume -add_setting definekey top XF86AudioRaiseVolume music_player_increase_volume -add_alias alias close_window exec ratpoison -c 'delete' -if command -v ocrdesktop &> /dev/null ; then -add_setting definekey top Print exec $(command -v ocrdesktop) -d -fi -add_setting bind exclam run_dialog -add_alias alias ratpoison_keybindings exec 'f=$(mktemp);ratpoison -c "help root" > $f && yad --text-info --show-cursor --title "Ratpoison Keybindings" --button "Close:0" --filename "$f";rm "$f"' -add_setting bind question ratpoison_keybindings -# Figure out which terminal emulator to use: -unset programList -for i in gnome-terminal lxterminal mate-terminal terminator tilda xfce4-terminal; do -if hash ${i/#-/} &> /dev/null ; then -if [ -n "$programList" ]; then -programList="$programList $i" -else -programList="$i" -fi -fi -done -if [ -z "$programList" ]; then -die "No terminal emulator found, please install one of lxterminal mate-terminal terminator, or xfce4-terminal." -fi -if [ "$programList" != "${programList// /}" ]; then -terminal="$(menulist "Terminal emulator:" $programList)" -else -terminal="${programList/#-/}" -fi -# Configure file browser -unset programList -for i in caja nemo nautilus pcmanfm pcmanfm-qt thunar ; do -if hash ${i/#-/} &> /dev/null ; then -if [ -n "$programList" ]; then -programList="$programList $i" -else -programList="$i" -fi -fi -done -if [ "$programList" != "${programList// /}" ]; then -fileBrowser="$(menulist "File browser:" $programList)" -else -fileBrowser="${programList/#-/}" -fi -if [ -n "$fileBrowser" ]; then -fileBrowser="$(command -v $fileBrowser)" -fi -add_setting bind f exec $fileBrowser -# Configure web browser -unset programList -for i in brave chromium epiphany firefox google-chrome-stable midori seamonkey ; do -if hash ${i/#-/} &> /dev/null ; then -if [ -n "$programList" ]; then -programList="$programList $i" -else -programList="$i" -fi -fi -done -if [ "$programList" != "${programList// /}" ]; then -webBrowser="$(menulist "Web browser:" $programList)" -else -webBrowser="${programList/#-/}" -fi -if [ -n "$webBrowser" ]; then -webBrowser="$(command -v $webBrowser)" -fi -add_setting bind w exec $webBrowser -add_setting bind W exec $webBrowser '$(ratpoison -c getsel) # Open selected URI in web browser' -# Configure text editor -unset programList -for i in geany gedit kate kwrite l3afpad leafpad libreoffice mousepad pluma ; do -if hash ${i/#-/} &> /dev/null ; then -if [ -n "$programList" ]; then -programList="$programList $i" -else -programList="$i" -fi -fi -done -if [ "$programList" != "${programList// /}" ]; then -textEditor="$(menulist "Text editor:" $programList)" -else -textEditor="${programList/#-/}" -fi -if [ -n "$textEditor" ]; then -textEditor="/usr/bin/$textEditor" -fi -add_setting bind e exec $textEditor -if hash gasher &> /dev/null ; then -add_setting bind g exec EDITOR="$textEditor" gasher -p '# Post to GNU Social with Gasher' -fi -if hash mumble &> /dev/null ; then -add_setting bind m exec /usr/bin/mumble -fi -if command -v pidgin &> /dev/null ; then -add_setting bind p exec $(command -v pidgin) -fi -if command -v talking-clock &> /dev/null ; then -add_setting bind M-t exec $(command -v talking-clock) '-c' -fi -add_setting bind c exec /usr/bin/$terminal -add_setting bind C-c exec /usr/bin/$terminal -add_setting "# Music player bindings:" -add_alias "alias music_player_previous_track exec playerctl previous && $notify \"\$(playerctl metadata -f '"{{title}}" by "{{artist}}"')\"" -add_alias "alias music_player_play exec playerctl play && $notify \"\$(playerctl metadata -f '"{{title}}" by "{{artist}}"')\"" -add_alias "alias music_player_pause exec playerctl play-pause && $notify \"\$(playerctl metadata -f '"{{title}}" by "{{artist}}" {{status}}')\"" -add_alias "alias music_player_stop exec playerctl stop" -add_alias "alias music_player_next_track exec playerctl next && $notify \"\$(playerctl metadata -f '"{{title}}" by "{{artist}}"')\"" -add_alias "alias music_player_decrease_volume exec playerctl volume 0.5-" -add_alias "alias music_player_increase_volume exec playerctl volume 0.5+" -add_alias "alias music_player_show_info exec $notify \"\$(playerctl metadata -f '"{{title}}" by "{{artist}}" from "{{album}}" via {{playerName}}')\"" -add_setting "bind M-Z music_player_previous_track" -add_setting "bind M-X music_player_play" -add_setting "bind M-C music_player_pause" -add_setting "bind M-V music_player_stop" -add_setting "bind M-B music_player_next_track" -add_setting "bind M-underscore music_player_decrease_volume" -add_setting "bind M-plus music_player_increase_volume" -add_setting "bind M-U music_player_show_info" +# Create the i3 configuration directory. +mkdir -p "${i3Path}" +# Move scripts into place +cp -rv scripts/ "${i3Path}/scripts" -add_alias 'alias run_dialog exec historyPath="${XDG_CONFIG_HOME:-$HOME/.config}/strychnine";if ! [ -d "$historyPath" ]; then mkdir -p "$historyPath";fi;write_history(){ oldHistory="$(grep -v "$txt" "$historyPath/history" | head -n 49)";echo -e "$txt\n$oldHistory" | sed '"'s/^$//g'"' > "$historyPath/history"; };if [ -f "$historyPath/history" ]; then txt=$(yad --entry --editable --title "Ratpoison" --text "Execute program or enter file" --button "Open:0" --separator "\n" --rest "$historyPath/history");else txt=$(yad --entry --title "Ratpoison" --text "Execute program or enter file" --button "Open:0");fi;if [ -z "$txt" ]; then exit 0;fi;if [[ "$txt" =~ ^ftp://|http://|https://|www.* ]]; then '"$webBrowser"' $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 "Ratpoison" -;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' -add_alias 'alias run_in_terminal_dialog exec c="$(yad --entry --title "Ratpoison" --text "Enter command:")" &&' /usr/bin/$terminal -e '$c' -add_setting bind C-exclam run_in_terminal_dialog -add_alias alias set_window_name exec 't="$(yad --entry --title "Ratpoison" --text "Enter window name") && ratpoison -c "title $t"' -add_setting bind C-A set_window_name -add_setting bind A set_window_name -add_alias alias show_date exec "$notify" '"$(date +"%A, %B %d, %Y%n%I:%M%p")"' -add_setting bind C-a show_date -add_setting bind a show_date -add_setting bind C-t show_date -add_setting bind O exec /usr/bin/orca -r '# Restart Orca' -add_alias alias ratpoison_version exec "$notify" '"$(ratpoison -c "version")"' -add_setting bind C-v ratpoison_version -add_setting bind v ratpoison_version -add_alias alias window_menu exec 'ifs="$IFS";IFS=$'"'"\\n"'"';w="$(yad --list --title "Ratpoison" --text "Select Window" --column "Select" $(ratpoison -c "windows"))";IFS="$ifs";ratpoison -c "select ${w:0:1}"' -add_setting bind C-apostrophe window_menu -add_setting bind apostrophe window_menu -add_alias alias run_ratpoison_command exec 'c="$(yad --entry --title "Ratpoison" --text="Enter Ratpoison command:")" && ratpoison -c "$c"' -add_setting bind colon run_ratpoison_command -add_alias alias reload_ratpoison_configuration exec ratpoison -c "\"source $HOME/.ratpoisonrc\"&&$notify \"Ratpoison configuration reloaded\"" -add_setting bind C-colon reload_ratpoison_configuration -add_setting bind C-M-r restart -add_setting bind C-M-q quit -# Sound for new window. -windowSound="$(yesno "Should new windows, and ratpoison keys make sounds?")" -#add_alias addhook switchwin speak_window_title -if [[ "$windowSound" == "yes" ]]; then -add_alias addhook newwindow announce_new_window -add_alias addhook key announce_top_level_key -add_alias alias announce_new_window exec bash -c $'\'excludedWindowNames="zenity";winName="$(ratpoison -c "info %t")";if ! [[ "$winName" =~ ^(${excludedWindowNames})$ ]]; then play -n synth .25 sin 440:880 sin 480:920 remix - norm -3 pitch -500;fi\'' -add_alias alias announce_top_level_key exec 'play -qV0 "|sox -np synth .07 sq 400" "|sox -np synth .5 sq 800" fade h 0 .5 .5 norm -20' -#add_alias alias 'speak_window_title exec bash -c' "'"'windowName="$(ratpoison -c "info %t")";socketFile="$(find /tmp -maxdepth 1 -name "orca-*.sock")"; [[ -w "$socketFile" ]] && echo "$windowName" | socat - UNIX-CLIENT:"<#APPEND#>${socketFile}"'"'" -fi -# Load user defined settings -if [[ -r ~/.ratpoison_customizations ]]; then -add_setting '# Load user defined settings' -add_setting "source ${HOME}/.ratpoison_customizations" -fi +cat << EOF > ${i3Path}/config +# Generated by I38 (${0##*/}) https://github.com/stormdragon2976/I38 +# $(date '+%A, %B %d, %Y at %I:%M%p') -# Autostart section -add_setting $'\n'"# Autostart section" -if hash rpws &> /dev/null ; then -workspaces="$(rangebox "Number of workspaces:" 1 8 4)" -if [ $workspaces -gt 1 ]; then -add_setting exec /usr/bin/rpws init $workspaces -a -for i in $(seq $workspaces) ; do -add_alias alias go_to_workspace_$i exec rpws $i -add_alias alias move_current_application_to_workspace_$i rpwsm$i -add_setting definekey top C-F$i go_to_workspace_$i -add_setting definekey top C-S-F$i move_current_application_to_workspace_$i -done -fi -fi -if command -v transfersh &> /dev/null ; then -add_setting bind u transfer_file -add_alias alias transfer_file 'exec fileName="$(yad --title "Strychnine Upload File" --file)" && url="$(transfersh "${fileName}" | tee >(yad --title "Strychnine - Uploading ${fileName##*/} ..." --progress --pulsate --no-buttons --auto-close))" && echo "${url#*saved at: }" | tee >(yad --title "Strychnine - Upload URL" --show-cursor --show-uri --button yad-close --sticky --text-info) >(xclip -selection clipboard)' -fi -# Additional startup programs -if [ -n "$(find /usr -type f -name 'notification-daemon' 2> /dev/null)" ] ; then -add_setting "exec $(find /usr -type f -name 'notification-daemon' 2> /dev/null)" -fi -unset programs -brlapi="$(yesno "Do you want to use a braille display with Orca?")" -if [[ "$brlapi" == "yes" ]]; then -programs+=("$( command -v xbrlapi) --quiet") -fi -if command -v clipster &> /dev/null ; then -programs+=("$(command -v clipster) -d") -add_setting definekey top M-C-c exec clipster -s -fi -echo "Enter any programs you want started automatically one per line. Press enter on a blank line when you are finished." | fold -s -w $(tput cols) -read -p "Enter program or enter when done: " -e programName -while [[ -n "${programName}" ]]; do -programs+=("${programName}") -read -p "Enter program or enter when done: " -e programName -done -if [[ -n "$programs" ]]; then -for i in "${programs[@]}" ; do -add_setting exec "$i" -done -fi -add_setting exec 'if [ "$(gsettings get org.gnome.desktop.a11y.applications screen-reader-enabled)" != "true" ]; then gsettings set org.gnome.desktop.a11y.applications screen-reader-enabled true&&' "$notify \"QT5 accessibility enabled. You need to restart ratpoison for the changes to take affect.\""';fi' -add_setting exec /usr/bin/orca -if [ -f "$HOME/.ratpoisonrc" ]; then -continue="$(yesno "$HOME/.ratpoisonrc exists. Over write it?")" -if [ "$continue" = "no" ]; then -exit 0 -fi -fi -echo "$rc" > $HOME/.ratpoisonrc -echo >> $HOME/.ratpoisonrc -echo "# Alias Section">> $HOME/.ratpoisonrc -echo "$rpAlias" >> $HOME/.ratpoisonrc -exit 0 + +# i3 config file (v4) +# +# Please see https://i3wm.org/docs/userguide.html for a complete reference! +# +# This config file uses keycodes (bindsym) and was written for the QWERTY +# layout. +# +# To get a config file with the same key positions, but for your current +# layout, use the i3-config-wizard +# + +# Font for window titles. Will also be used by the bar unless a different font +# is used in the bar {} block below. +font pango:monospace 8 + +# Start XDG autostart .desktop files using dex. See also +# https://wiki.archlinux.org/index.php/XDG_Autostart +# exec --no-startup-id dex --autostart --environment i3 + +# Startup applications +exec clipster -d +exec /usr/lib/notification-daemon-1.0/notification-daemon +exec orca + +# Run dialog +bindsym Mod1+F2 exec grun + +# Clipboard manager +bindsym Mod1+Control+c exec clipster -s + +# gtk bar +bindsym Mod1+Control+Delete exec --no-startup-id sgtk-bar + +# Use pactl to adjust volume in PulseAudio. +set $refresh_i3status killall -SIGUSR1 i3status +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status + +# start a terminal +bindsym Mod1+Return exec i3-sensible-terminal + +# kill focused window +bindsym Mod1+F4 kill + +# Applications menu +bindsym Mod1+F1 exec --no-startup-id sgtk-menu -f + +# Desktop icons +bindsym Mod1+Control+d exec --no-startup-id yad --icons --compact --no-buttons --title="Desktop" --close-on-unfocus --read-dir=${HOME}/Desktop + +# change focus +# alt+tab and shift tab +bindsym Mod1+Shift+Tab focus left +bindsym Mod1+Tab focus right + +# enter fullscreen mode for the focused container +bindsym Mod1+BackSpace fullscreen toggle + +# focus the parent container +bindsym Mod1+a focus parent + +# focus the child container +#bindsym Mod1+d focus child + +# move the currently focused window to the scratchpad +bindsym Mod1+Shift+minus move scratchpad + +# Show the next scratchpad window or hide the focused scratchpad window. +# If there are multiple scratchpad windows, this command cycles through them. +bindsym Mod1+minus scratchpad show + +# Define names for default workspaces for which we configure key bindings later on. +# We use variables to avoid repeating the names in multiple places. +set \$ws1 "1" +set \$ws2 "2" +set \$ws3 "3" +set \$ws4 "4" +set \$ws5 "5" +set \$ws6 "6" +set \$ws7 "7" +set \$ws8 "8" +set \$ws9 "9" +set \$ws10 "10" + +# switch to workspace +bindsym Control+F1 workspace number \$ws1 +bindsym Control+F2 workspace number \$ws2 +bindsym Control+F3 workspace number \$ws3 +bindsym Control+F4 workspace number \$ws4 +bindsym Control+F5 workspace number \$ws5 +bindsym Control+F6 workspace number \$ws6 +bindsym Control+F7 workspace number \$ws7 +bindsym Control+F8 workspace number \$ws8 +bindsym Control+F9 workspace number \$ws9 +bindsym Control+F10 workspace number \$ws10 + +# move focused container to workspace +bindsym Control+Shift+F1 move container to workspace number \$ws1 +bindsym Control+Shift+F2 move container to workspace number \$ws2 +bindsym Control+Shift+F3 move container to workspace number \$ws3 +bindsym Control+Shift+F4 move container to workspace number \$ws4 +bindsym Control+Shift+F5 move container to workspace number \$ws5 +bindsym Control+Shift+F6 move container to workspace number \$ws6 +bindsym Control+Shift+F7 move container to workspace number \$ws7 +bindsym Control+Shift+F8 move container to workspace number \$ws8 +bindsym Control+Shift+F9 move container to workspace number \$ws9 +bindsym Control+Shift+F10 move container to workspace number \$ws10 + +# reload the configuration file +bindsym Mod1+Shift+c reload +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym Mod1+Shift+r restart +# exit i3 (logs you out of your X session) +bindsym Mod1+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'" + +# Start i3bar to display a workspace bar (plus the system information i3status +# finds out, if available) +bar { + status_command i3status +} +EOF