12 Commits
v2.0 ... v2.1

4 changed files with 194 additions and 107 deletions

View File

@ -15,13 +15,12 @@ An uppercase I looks like a 1, 3 from i3, and 8 because the song [We Are 138](ht
## 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. Required for the battery monitor with sound alerts.
- dex: [optional] Alternative method for auto starting applications.
- clipster: clipboard manager
- jq: for getting the current workspace
- libcanberra: [optional]To play the desktop login sound.
- libnotify: For sending notifications
- lxsession: For policykit authentication agent.
- notification-daemon: To handle notifications
- ocrdesktop: For getting contents of the current window with OCR.
- pamixer: for the mute-unmute script

191
i38.sh
View File

@ -26,94 +26,99 @@ if [[ -n "${missing}" ]]; then
fi
keyboard_menu() {
keyboardMenu=("us" "USA"
"ad" "Andorra"
"af" "Afghanistan"
keyboardMenu=("us" "English (US)"
"af" "Dari"
"al" "Albanian"
"et" "Amharic"
"ara" "Arabic"
"al" "Albania"
"am" "Armenia"
"az" "Azerbaijan"
"by" "Belarus"
"be" "Belgium"
"bd" "Bangladesh"
"in" "India"
"ba" "Bosnia and Herzegovina"
"br" "Brazil"
"bg" "Bulgaria"
"ma" "Morocco"
"mm" "Myanmar"
"ca" "Canada"
"cd" "Congo, Democratic Republic of the"
"cn" "China"
"hr" "Croatia"
"cz" "Czechia"
"dk" "Denmark"
"nl" "Netherlands"
"bt" "Bhutan"
"ee" "Estonia"
"ir" "Iran"
"iq" "Iraq"
"fo" "Faroe Islands"
"fi" "Finland"
"fr" "France"
"gh" "Ghana"
"gn" "Guinea"
"ge" "Georgia"
"de" "Germany"
"gr" "Greece"
"hu" "Hungary"
"is" "Iceland"
"il" "Israel"
"it" "Italy"
"jp" "Japan"
"kg" "Kyrgyzstan"
"kh" "Cambodia"
"kz" "Kazakhstan"
"la" "Laos"
"latam" "Latin American"
"lt" "Lithuania"
"lv" "Latvia"
"mao" "Maori"
"me" "Montenegro"
"mk" "Macedonia"
"mt" "Malta"
"mn" "Mongolia"
"no" "Norway"
"pl" "Poland"
"pt" "Portugal"
"ro" "Romania"
"ru" "Russia"
"rs" "Serbia"
"si" "Slovenia"
"sk" "Slovakia"
"es" "Spain"
"se" "Sweden"
"ch" "Switzerland"
"sy" "Syria"
"tj" "Tajikistan"
"lk" "Sri Lanka"
"th" "Thailand"
"tr" "Turkey"
"tw" "Taiwan"
"ua" "Ukraine"
"gb" "United Kingdom"
"uz" "Uzbekistan"
"vn" "Vietnam"
"kr" "Korea, Republic of"
"nec_vndr/jp" "Japan (PC-98xx Series)"
"ie" "Ireland"
"pk" "Pakistan"
"mv" "Maldives"
"za" "South Africa"
"epo" "Esperanto"
"np" "Nepal"
"ng" "Nigeria"
"et" "Ethiopia"
"sn" "Senegal"
"ma" "Arabic (Morocco)"
"sy" "Arabic (Syria)"
"am" "Armenian"
"az" "Azerbaijani"
"ml" "Bambara"
"bd" "Bangla"
"by" "Belarusian"
"be" "Belgian"
"dz" "Berber (Algeria, Latin)"
"ba" "Bosnian"
"brai" "Braille"
"tm" "Turkmenistan"
"ml" "Mali"
"tz" "Tanzania"
"bg" "Bulgarian"
"mm" "Burmese"
"cn" "Chinese"
"hr" "Croatian"
"cz" "Czech"
"dk" "Danish"
"mv" "Dhivehi"
"nl" "Dutch"
"bt" "Dzongkha"
"au" "English (Australia)"
"gh" "English (Ghana)"
"ng" "English (Nigeria)"
"za" "English (South Africa)"
"gb" "English (UK)"
"epo" "Esperanto"
"ee" "Estonian"
"fo" "Faroese"
"ph" "Filipino"
"fi" "Finnish"
"fr" "French"
"ca" "French (Canada)"
"cd" "French (Democratic Republic of the Congo)"
"ge" "Georgian"
"de" "German"
"ch" "German (Switzerland)"
"gr" "Greek"
"il" "Hebrew"
"hu" "Hungarian"
"is" "Icelandic"
"in" "Indian"
"jv" "Indonesian (Javanese)"
"iq" "Iraqi"
"ie" "Irish"
"it" "Italian"
"jp" "Japanese"
"nec_vndr/jp" "Japanese (PC-98)"
"kz" "Kazakh"
"kh" "Khmer (Cambodia)"
"kr" "Korean"
"kg" "Kyrgyz"
"la" "Lao"
"lv" "Latvian"
"lt" "Lithuanian"
"mk" "Macedonian"
"mv" "Malay (Jawi, Arabic Keyboard)"
"mt" "Maltese"
"mao" "Maori"
"mn" "Mongolian"
"me" "Montenegrin"
"gn" "N'Ko (AZERTY)"
"np" "Nepali"
"no" "Norwegian"
"ir" "Persian"
"pl" "Polish"
"pt" "Portuguese"
"br" "Portuguese (Brazil)"
"ro" "Romanian"
"ru" "Russian"
"rs" "Serbian"
"lk" "Sinhala (phonetic)"
"sk" "Slovak"
"si" "Slovenian"
"es" "Spanish"
"latam" "Spanish (Latin American)"
"tz" "Swahili (Tanzania)"
"se" "Swedish"
"tw" "Taiwanese"
"tj" "Tajik"
"th" "Thai"
"tr" "Turkish"
"tm" "Turkmen"
"bw" "Tswana"
"ua" "Ukrainian"
"pk" "Urdu (Pakistan)"
"uz" "Uzbek (Afghanistan)"
"vn" "Vietnamese"
"sn" "Wolof"
)
dialog --title "I38" \
--backtitle "Use the arrow keys to find the option you want, and enter to select it. When you are finished selecting layouts, use right arrow to find \"Done\" and press enter." \
@ -362,6 +367,10 @@ fi
if [[ $dex -eq 0 ]]; then
dex -t "${XDG_CONFIG_HOME:-${HOME}/.config}/autostart" -c $(command -v orca)
fi
if command -v acpi &> /dev/null ; then
batteryAlert=1
batteryAlert=$(yesno "Do you want low battery notifications?")
fi
brlapi=1
brlapi=$(yesno "Do you want to use a braille display with Orca?")
sounds=1
@ -383,7 +392,7 @@ mkdir -p "${i3Path}"
cp -rv scripts/ "${i3Path}/" | dialog --backtitle "I38" --progressbox "Moving scripts into place and writing config..." -1 -1
cat << EOF > ${i3Path}/config
# Generated by I38 (${0##*/}) https://github.com/stormdragon2976/I38
# Generated by I38 (${0##*/}) https://git.stormux.org/storm/I38
# $(date '+%A, %B %d, %Y at %I:%M%p')
@ -589,7 +598,7 @@ bindsym Shift+o exec $(command -v orca) --replace, mode "default"
# reload the configuration file
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)
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 'killall remind || true && $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)
@ -618,9 +627,6 @@ fi
if [[ $udiskie -eq 0 ]]; then
echo 'exec --no-startup-id udiskie'
fi
if command -v lxpolkit &> /dev/null ; then
echo "exec_always --no-startup-id $(command -v lxpolkit)"
fi
if [[ -x "/usr/lib/notification-daemon-1.0/notification-daemon" ]]; then
echo 'exec_always --no-startup-id /usr/lib/notification-daemon-1.0/notification-daemon -r'
fi
@ -632,6 +638,9 @@ if command -v remind &> /dev/null && command -v notify-send &> /dev/null ; then
echo "exec_always --no-startup-id $(command -v remind) -z '-k:${HOME}/.config/i3/scripts/reminder.sh %s &' ${HOME}/.reminders < /dev/null > /dev/null 2>&1"
touch ~/.reminders
fi
if [[ $batteryAlert -eq 0 ]]; then
echo "exec_always --no-startup-id ${i3Path}/scripts/battery_alert.sh"
fi
if [[ $dex -eq 0 ]]; then
echo '# Start XDG autostart .desktop files using dex. See also'
echo '# https://wiki.archlinux.org/index.php/XDG_Autostart'

25
scripts/battery_alert.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
if ! command -v acpi &> /dev/null ; then
exit 0
fi
while : ; do
acpi -b | awk -F'[,:%]' '{print $2, $3}' | {
read -r status capacity
if [[ "$status" == "Discharging" ]] && [[ "$capacity" -le 15 ]] && [[ "$capacity" -gt 10 ]]; then
play -qV0 "|sox -n -p synth saw E2 fade 0 0.25 0.05" "|sox -n -p synth saw E2 fade 0 0.25 0.05" norm -7
spd-say -P important "Battery $capacity percent."
elif [[ "$status" == "Discharging" ]] && [[ "$capacity" -le 10 ]] && [[ "$capacity" -gt 5 ]]; then
play -qV0 "|sox -n -p synth saw E2 fade 0 0.25 0.05" "|sox -n -p synth saw E2 fade 0 0.25 0.05" norm -7
spd-say -P important "Battery $capacity percent."
elif [[ "$status" == "Discharging" ]] && [[ "$capacity" -lt 5 ]]; then
play -qV0 "|sox -np synth sq C#5 sq D#5 sq F#5 sq A5 sq C#6" remix - fade 0 5.5 5 pitch -400
spd-say -P important "Battery $capacity percent."
fi
}
sleep 5m
done
exit 0

View File

@ -8,6 +8,55 @@ message() {
yad --form --selectable-labels --title "I38 - Reminder" --field="${*}":lbl --button="Close!gtk-ok":0
}
add_reminder() {
info="$(yad --form --selectable-labels \
--title "I38 - New Reminder" \
--field="Comment for ~/.reminders file":lbl "" \
--field="Reminder Comment" "# Added by I38" \
--field="Enter date in yyyy-mm-dd format:":lbl "" \
--field="Date" "$(date '+%Y-%m-%d')" \
--field="Reminder text:":lbl "" \
--field="Reminder" "" \
--field="Select Hour:":num '1!1..12' \
--field="Select Minute:":num '0!0..59' \
--field="Select AM or PM":cb 'AM!PM' \
--button="Cancel!gtk-cancel:1" \
--button="Create Reminder!gtk-ok:0")"
if [[ $? -eq 1 || $? -eq 252 ]]; then
return
fi
while [[ $info =~ \|\| ]]; do
info="${info//||/|}"
done
info="${info#|#}"
# Get information for reminder into an array
IFS='|' read -a reminder <<< $info
# Fix time to be 2 digits.
[[ ${#reminder[3]} -eq 1 ]] && reminder[3]="0${reminder[3]}"
[[ ${#reminder[4]} -eq 1 ]] && reminder[4]="0${reminder[4]}"
# Check date format
if ! [[ "${reminder[1]}" =~ ^[2-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$ ]]; then
error "Invalid date format given, addition canceled."
return
fi
if [[ ${#reminder[2]} -lt 3 ]]; then
error "No reminder text given, addition canceled."
return
fi
# Add reminder
if [[ "${reminder[0]}" != "# " ]]; then
echo "# ${reminder[0]}" >> ~/.reminders
fi
echo "REM $(date -d "${reminder[1]}" '+%b %d %Y') AT ${reminder[3]}:${reminder[4]}${reminder[5]} +5 MSG ${reminder[2]} %2." >> ~/.reminders
if [[ -N ~/.reminders ]]; then
message "Reminder added."
else
error "Something went wrong. The reminder was not added."
fi
}
add_custom_reminder() {
info="$(yad --form --selectable-labels \
--title "I38 - New Custom Reminder" \
@ -271,50 +320,55 @@ if [[ $# -ne 0 ]]; then
fi
if command -v xclip &> /dev/null && [[ "${#url}" -gt 3 ]]; then
echo "${url}" | xclip -selection clipboard
notify-send "${notification} The URL has been copied to the clipboard." --expire-time=30000
notify-send --hint=int:transient:1 -t 500 -r 38 "${notification} The URL has been copied to the clipboard."
else
notify-send "${*}" --expire-time=30000
notify-send --hint=int:transient:1 -t 500 -r 38 "${*}"
fi
exit 0
fi
while : ; do
action=$(yad --title "I38 - Reminders" --form \
--button="_View Today's Reminders!gtk-info":2 \
--button="_View All Reminders!gtk-info":3 \
--button="_Add Daily Reminder!gtk-edit":0 \
--button="_Add Weekly Reminder!gtk-edit":4 \
--button="Add Monthly Reminder!gtk-edit":5 \
--button="Add Custom Reminder!gtk-edit":6 \
--button="_View Today's Reminders!gtk-info":3 \
--button="_View All Reminders!gtk-info":4 \
--button="_Add Reminder!gtk-edit":0 \
--button="_Add Daily Reminder!gtk-edit":2 \
--button="_Add Weekly Reminder!gtk-edit":5 \
--button="Add Monthly Reminder!gtk-edit":6 \
--button="Add Custom Reminder!gtk-edit":7 \
--button="Close!gtk-cancel":1 \
--separator="")
case $? in
0)
# Handle "Add Daily Reminder" button click
add_daily_reminder
# Single reminder
add_reminder
;;
1|252)
# Handle "Close" button click and escape.
exit 0
;;
2)
# Handle "Add Daily Reminder" button click
add_daily_reminder
;;
3)
# View today's reminders
view_today
;;
3)
4)
# View reminders
view_reminders
;;
4)
5)
# Handle "Add Weekly Reminder" button click
add_weekly_reminder
;;
5)
6)
# Handle "Add Monthly Reminder" button click
add_monthly_reminder
;;
6)
7)
# Handle "Add Custom Reminder" button click
add_custom_reminder
;;