From fccfc90acee278763c060e0717778be35e12fefb Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Wed, 19 Feb 2020 15:50:15 +0000 Subject: [PATCH 01/26] Update i3 font, add Bitwarden app settings, add weather / wifi to i3blocks --- .config/i3/config | 9 ++++++++- .config/i3blocks/config | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.config/i3/config b/.config/i3/config index 06355a2..71631c9 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -22,7 +22,8 @@ bindsym $mod+Shift+z exec --no-startup-id $HOME/.local/bin/i3scripts/i3empty.py # 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 +font pango:Inconsolata Nerd Font Mono 10 +#font pango:monospace 8 # This font is widely installed, provides lots of unicode glyphs, right-to-left # text rendering and scalability on retina/hidpi displays (thanks to pango). @@ -199,6 +200,12 @@ for_window [class="Pavucontrol"] resize set height 400 for_window [class="Pavucontrol"] resize set width 600 for_window [class="Pavucontrol"] move position center +for_window [class="Bitwarden"] floating enable +for_window [class="Bitwarden"] resize set height 600 +for_window [class="Bitwarden"] resize set width 800 +for_window [class="Bitwarden"] move position center + + for_window [class="Wicd-client.py"] floating enable for_window [class="Wicd-client.py"] resize set height 400 for_window [class="Wicd-client.py"] resize set width 600 diff --git a/.config/i3blocks/config b/.config/i3blocks/config index 76910c7..43fa76b 100644 --- a/.config/i3blocks/config +++ b/.config/i3blocks/config @@ -28,9 +28,17 @@ command=/usr/share/i3blocks/$BLOCK_NAME separator_block_width=20 markup=none -[nm-tray] +[weather] +command=sh $HOME/.local/bin/i3scripts/weathermap +align=right +color=#ffaf00 +interval=1800 + + + +[wicd-wifi] #label= -command=nm-tray +command=sudo pkill wicd-client && wicd-client -t interval=once # Volume indicator From e1d466362dd64ab914e30b4b0bdb358ac5f6d0fc Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Wed, 19 Feb 2020 15:52:34 +0000 Subject: [PATCH 02/26] Add better mouse plugin to tmux to adjust sensitive scrolling --- .tmux.conf | 10 +- .../tmux-better-mouse-mode/.travis.yml | 10 ++ .../plugins/tmux-better-mouse-mode/LICENSE.md | 21 ++++ .../plugins/tmux-better-mouse-mode/README.md | 103 ++++++++++++++++++ .../only_scroll_sometimes.sh | 22 ++++ .../tmux-better-mouse-mode/scripts/helpers.sh | 15 +++ .../scroll_copy_mode.tmux | 100 +++++++++++++++++ .../tests/basic_functionality_test.sh | 74 +++++++++++++ 8 files changed, 352 insertions(+), 3 deletions(-) create mode 100644 .tmux/plugins/tmux-better-mouse-mode/.travis.yml create mode 100644 .tmux/plugins/tmux-better-mouse-mode/LICENSE.md create mode 100644 .tmux/plugins/tmux-better-mouse-mode/README.md create mode 100755 .tmux/plugins/tmux-better-mouse-mode/only_scroll_sometimes.sh create mode 100644 .tmux/plugins/tmux-better-mouse-mode/scripts/helpers.sh create mode 100755 .tmux/plugins/tmux-better-mouse-mode/scroll_copy_mode.tmux create mode 100644 .tmux/plugins/tmux-better-mouse-mode/tests/basic_functionality_test.sh diff --git a/.tmux.conf b/.tmux.conf index b8a7639..99a10dc 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -109,8 +109,12 @@ set -g default-terminal "screen-256color" # Mode set -g mode-style bg=colour100,fg=colour235 -# List of plugins -#set -g @plugin 'tmux-plugins/tpm' +# List of plugins and their settings +set -g @plugin 'tmux-plugins/tpm' + +set -g @plugin 'nhdaly/tmux-better-mouse-mode' +set -g @scroll-speed-num-lines-per-scroll 2 + #set -g @plugin 'tmux-plugins/tmux-sensible' #set -g @plugin 'kristijanhusak/tmux-simple-git-status' @@ -120,5 +124,5 @@ set -g mode-style bg=colour100,fg=colour235 # set -g @plugin 'git@bitbucket.com/user/plugin' # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) -#run -b '~/.tmux/plugins/tpm/tpm' +run -b '~/.tmux/plugins/tpm/tpm' diff --git a/.tmux/plugins/tmux-better-mouse-mode/.travis.yml b/.tmux/plugins/tmux-better-mouse-mode/.travis.yml new file mode 100644 index 0000000..a874cc3 --- /dev/null +++ b/.tmux/plugins/tmux-better-mouse-mode/.travis.yml @@ -0,0 +1,10 @@ +language: bash + +before_script: + - curl -L "https://github.com/tmux/tmux/releases/download/2.2/tmux-2.2.tar.gz" | tar zx + - cd tmux-2.2; ./configure && make; cd .. + - curl -L "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/shunit2/shunit2-2.1.6.tgz" | tar zx + +script: + - bash tests/*.sh + diff --git a/.tmux/plugins/tmux-better-mouse-mode/LICENSE.md b/.tmux/plugins/tmux-better-mouse-mode/LICENSE.md new file mode 100644 index 0000000..6755fc0 --- /dev/null +++ b/.tmux/plugins/tmux-better-mouse-mode/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Nathan Daly + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/.tmux/plugins/tmux-better-mouse-mode/README.md b/.tmux/plugins/tmux-better-mouse-mode/README.md new file mode 100644 index 0000000..3b9b408 --- /dev/null +++ b/.tmux/plugins/tmux-better-mouse-mode/README.md @@ -0,0 +1,103 @@ +# Tmux Better Mouse Mode +A tmux plugin to better manage the mouse. + +Provides options to control mouse behavior in tmux, so it will behave exactly how you want: + - Emulate mouse-support for full-screen programs like `less` that don't provide built in mouse support. + - Exit `copy-mode` and return to your prompt by scrolling back all the way down to the bottom. + - Adjust your scrolling speed. + - And more! + +Finally, `tmux` version 2.1 introduced backwards-incompatible changes to the mouse behavior, and this plugin restores the old mouse behavior. `tmux` version 2.2 mostly restores the 2.0 mouse behavior, but this plugin improves tmux mouse mode beyond those changes and provides you with more control. + +### Requirements + +This plugin is intended for `tmux` version 2.1 and higher. It does not work for 2.0 or below. + +NOTE: This plugin provides options to *change* the mouse-mode behavior, but does not enable mouse-mode. + +To enable mouse-mode in tmux 2.1+, put the following line in your `~/.tmux.conf`: + + set-option -g mouse on + +### Key bindings + +This plugin will overwrite the values for `WheelUpPane` and `WheelDownPane` in tmux in order to configure mouse scrolling. + +To see your current setting for these variables, check the output of `tmux list-keys -T root`. + +### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended) + +1. Add this plugin to the list of TPM plugins in `.tmux.conf`: + + set -g @plugin 'nhdaly/tmux-better-mouse-mode' + +1. Press `prefix` + I or run `$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/install_plugins.sh` to fetch the plugin and source it. You should now be able to +use the plugin. + +1. To enable mouse-mode in tmux 2.1+, put the following line in your `.tmux.conf`: + + set-option -g mouse on + +### Manual Installation + +1. Clone the repo: + + $ git clone https://github.com/nhdaly/tmux-better-mouse-mode ~/clone/path + +1. Add this line to the bottom of `.tmux.conf`: + + run-shell ~/clone/path/scroll_copy_mode.tmux + +1. Reload TMUX environment: + + # type this in terminal + $ tmux source-file ~/.tmux.conf + +You should now be able to use the plugin. + +### Configuration + +Set these options in `.tmux.conf`. For example, `set -g @scroll-down-exit-copy-mode "off"` to disable scrolling down exits copy-mode. + +- `scroll-down-exit-copy-mode` - When enabled, the pane exits `copy-mode` when scrolling hits the bottom of the scroll-back history. + - "on" (default) - Scrolling can exit `copy-mode`. + - "off" - Scrolling to bottom will stay in `copy-mode`. + +- `scroll-without-changing-pane` - When enabled, scrolling the mouse will not select the moused-over pane, allowing you to scroll a window just to read previous output and then keep typing in the current pane. Enabling this feature is a change from `tmux 2.0` settings, but may be an improvement. + - "on" - Scroll events are sent to moused-over pane. + - "off" (default) - Scroll events stay in currently selected pane. + +- `scroll-in-moused-over-pane` - When enabled, scrolling with your mouse over a pane will perform the scroll in that pane, instead of the currently selected one. If `scroll-without-changing-pane` is set to `"off"`, this will also select the moused-over pane. + - "on" (default) - Scroll events select and scroll the moused-over pane. + - "off" - Scroll events are ingored unless the mouse is over the currently selected pane. + +- `scroll-speed-num-lines-per-scroll` - Sets the number of lines to scroll per mouse wheel scroll event. The default option is 3, which was the scroll speed in `tmux 2.0`. Larger numbers scroll faster. To slow down scrolling to slower than one line per wheel click, set the value to a decimal between 0.0 and 1.0. With a decimal value, only that fraction of wheel events will take effect. The value must be > 0. Examples: + - "3" (default) - Scroll three lines per every mouse wheel click. + - "1" - One line per mouse wheel scroll click (smoothest). + - "0.5" - Scroll one line only on every other mouse wheel scroll click. + - "0.25" - Scroll one line only on every fourth mouse wheel scroll click. + +- `emulate-scroll-for-no-mouse-alternate-buffer` - When enabled, tmux will emulate scrolling for "full-screen", alternate buffer programs, such as `less`, `man`, or `vi` that don't themselves already support mouse interactions. It will not enter `copy-mode` and will not scroll through pane output history, but will instead send `` () and ``() keys to the application. The scroll speed is also set by `@scroll-speed-num-lines-per-scroll` above. +This option defaults to "off", which matches the behavior in `tmux 2.0`. Note, though, that this default behavior may be undesirable since the pane history gets munged when entering a full-screen alternate buffer program. It's a pretty great option is all I'm saying. + - "on" - and keys are passed to the alternate buffer program on scroll events. + - "off" (default) - Scroll event causes scrollback in pane output. + +### Contributions +[@nhdaly](https://github.com/nhdaly) +[@corv89](https://github.com/corv89) +[@pallxk ](https://github.com/pallxk ) +[@hughdavenport](https://github.com/hughdavenport) +[@giddie](https://github.com/giddie) +[@pochemuto](https://github.com/pochemuto) +[@zeorin](https://github.com/zeorin) +[@alcesleo](https://github.com/alcesleo) +[@iamjamestl](https://github.com/iamjamestl) + +### Inspiration + +Inspired by David Verhasselt's in depth article on Tmux 2.1's changes to Mouse support and scrolling: +http://www.davidverhasselt.com/better-mouse-scrolling-in-tmux/ + +### License +[MIT](LICENSE.md) + diff --git a/.tmux/plugins/tmux-better-mouse-mode/only_scroll_sometimes.sh b/.tmux/plugins/tmux-better-mouse-mode/only_scroll_sometimes.sh new file mode 100755 index 0000000..5edf63b --- /dev/null +++ b/.tmux/plugins/tmux-better-mouse-mode/only_scroll_sometimes.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +num_scrolls_to_scroll=$1 + +get_count_cmd=`tmux show-environment -g __scroll_copy_mode__slow_scroll_count` +eval $get_count_cmd + +# Save the current count so we can use it in the return statement at the end. +CURRENT_COUNT=$__scroll_copy_mode__slow_scroll_count + +# Now increment and loop around if we've finished the scroll cycle. +__scroll_copy_mode__slow_scroll_count=$(( (__scroll_copy_mode__slow_scroll_count + 1) % num_scrolls_to_scroll)) + + +# Store the new value in tmux. +tmux set-environment -g __scroll_copy_mode__slow_scroll_count $__scroll_copy_mode__slow_scroll_count + +# Return true if this is the first scroll for this scroll-cycle, and false if we haven't hit the end of the cycle. +[ $CURRENT_COUNT -eq 0 ] + + + diff --git a/.tmux/plugins/tmux-better-mouse-mode/scripts/helpers.sh b/.tmux/plugins/tmux-better-mouse-mode/scripts/helpers.sh new file mode 100644 index 0000000..2c263c4 --- /dev/null +++ b/.tmux/plugins/tmux-better-mouse-mode/scripts/helpers.sh @@ -0,0 +1,15 @@ +get_tmux_option() { + local option="$1" + local default_value="$2" + local option_value=$(tmux show-option -gqv "$option") + if [ -z "$option_value" ]; then + echo "$default_value" + else + echo "$option_value" + fi +} + +get_tmux_version() { + tmux -V | cut -d " " -f 2 +} + diff --git a/.tmux/plugins/tmux-better-mouse-mode/scroll_copy_mode.tmux b/.tmux/plugins/tmux-better-mouse-mode/scroll_copy_mode.tmux new file mode 100755 index 0000000..0d7dfbc --- /dev/null +++ b/.tmux/plugins/tmux-better-mouse-mode/scroll_copy_mode.tmux @@ -0,0 +1,100 @@ +#!/usr/bin/env bash + +CURRENT_DIR="$( dirname "$0" )" + +. "$CURRENT_DIR/scripts/helpers.sh" + +scroll_down_exit_copy_mode_option="@scroll-down-exit-copy-mode" +scroll_in_moused_over_pane_option="@scroll-in-moused-over-pane" +scroll_without_changing_pane_option="@scroll-without-changing-pane" +scroll_speed_num_lines_per_scroll_option="@scroll-speed-num-lines-per-scroll" +deprecated_prevent_scroll_for_fullscreen_alternate_buffer_option="@prevent-scroll-for-fullscreen-alternate-buffer" +emulate_scroll_for_no_mouse_alternate_buffer_option="@emulate-scroll-for-no-mouse-alternate-buffer" + +get_repeated_scroll_cmd() { + local scroll_speed_num_lines_per_scroll=$(get_tmux_option "$scroll_speed_num_lines_per_scroll_option" "3") + local cmd="" + if echo - | awk "{ if ($scroll_speed_num_lines_per_scroll >= 1) { exit 0 } else { exit 1 } }" ; then # Positive whole number speed (round down). + for ((i = 1; i <= scroll_speed_num_lines_per_scroll; i++)); do + cmd=$cmd"send-keys $1 ; " + done + elif echo - | awk "{ if ($scroll_speed_num_lines_per_scroll > 0) { exit 0 } else { exit 1 } }" ; then # Positive decimal between 0 and 1 (treat as percent). + # Skip enough scrolls so that we scroll only on the specified percent of scrolls. + local num_scrolls_to_scroll=`echo - | awk "{print int( 1/$scroll_speed_num_lines_per_scroll ) }"` + tmux set-environment __scroll_copy_mode__slow_scroll_count 0; + cmd="if -t = \\\"$CURRENT_DIR/only_scroll_sometimes.sh $num_scrolls_to_scroll\\\" \\\"send-keys $1\\\" \\\"\\\""; + fi + echo "$cmd" +} + +better_mouse_mode_main() { + local scroll_down_to_exit=$(get_tmux_option "$scroll_down_exit_copy_mode_option" "on") + local scroll_in_moused_over_pane=$(get_tmux_option "$scroll_in_moused_over_pane_option" "on") + local scroll_without_changing_pane=$(get_tmux_option "$scroll_without_changing_pane_option" "off") + local deprecated_prevent_scroll_for_fullscreen_alternate_buffer=$(get_tmux_option "$deprecated_prevent_scroll_for_fullscreen_alternate_buffer_option" "off") + local emulate_scroll_for_no_mouse_alternate_buffer=$(get_tmux_option "$emulate_scroll_for_no_mouse_alternate_buffer_option" "$deprecated_prevent_scroll_for_fullscreen_alternate_buffer") + + local enter_copy_mode_cmd="copy-mode" + local select_moused_over_pane_cmd="" + local check_for_fullscreen_alternate_buffer="" + if [ "$scroll_down_to_exit" = 'on' ] ; then + enter_copy_mode_cmd="copy-mode -e" + fi + if [ "$scroll_in_moused_over_pane" = 'on' ] ; then + select_moused_over_pane_cmd="select-pane -t= ;" + fi + if [ "$scroll_without_changing_pane" = 'on' ] ; then + enter_copy_mode_cmd="$enter_copy_mode_cmd -t=" + select_moused_over_pane_cmd="" + fi + if [ "$emulate_scroll_for_no_mouse_alternate_buffer" = 'on' ] ; then + check_for_fullscreen_alternate_buffer="#{alternate_on}" + fi + + # Start copy mode when scrolling up and exit when scrolling down to bottom. + # The "#{mouse_any_flag}" check just sends scrolls to any program running that + # has mouse support (like vim). + # NOTE: the successive levels of quoting commands gets a little confusing + # here. Tmux uses quoting to denote levels of the if-blocks below. The + # pattern used here for consistency is " \" ' \\\" \\\" ' \" " -- that is, + # " for top-level quotes, \" for the next level in, ' for the third level, + # and \\\" for the fourth (note that the fourth comes from inside get_repeated_scroll_cmd). + tmux bind-key -n WheelUpPane \ + if -Ft= "#{mouse_any_flag}" \ + "send-keys -M" \ + " \ + if -Ft= '$check_for_fullscreen_alternate_buffer' \ + \"$(get_repeated_scroll_cmd "-t= up")\" \ + \" \ + $select_moused_over_pane_cmd \ + if -Ft= '#{pane_in_mode}' \ + '$(get_repeated_scroll_cmd -M)' \ + '$enter_copy_mode_cmd ; $(get_repeated_scroll_cmd -M)' \ + \" \ + " + # Enable sending scroll-downs to the moused-over-pane. + # NOTE: the quoting pattern used here and in the above command for + # consistency is " \" ' \\\" \\\" ' \" " -- that is, " for top-level quotes, + # \" for the next level in, ' for the third level, and \\\" for the fourth + # (note that the fourth comes from inside get_repeated_scroll_cmd). + tmux bind-key -n WheelDownPane \ + if -Ft= "#{mouse_any_flag}" \ + "send-keys -M" \ + " \ + if -Ft= \"$check_for_fullscreen_alternate_buffer\" \ + \"$(get_repeated_scroll_cmd "-t= down")\" \ + \"$select_moused_over_pane_cmd $(get_repeated_scroll_cmd -M)\" \ + " + + # For tmux 2.4+ you have to set the mouse wheel options seperately for copy-mode than from root. + local tmux_version=$(get_tmux_version) + if echo - | awk "{ if ($tmux_version >= 2.4) { exit 0 } else { exit 1 } }" ; then # Use copy-mode tables to set scroll speed. + local scroll_speed_num_lines_per_scroll=$(get_tmux_option "$scroll_speed_num_lines_per_scroll_option" "3") + tmux bind-key -Tcopy-mode WheelUpPane send -N"$scroll_speed_num_lines_per_scroll" -X scroll-up + tmux bind-key -Tcopy-mode WheelDownPane send -N"$scroll_speed_num_lines_per_scroll" -X scroll-down + tmux bind-key -Tcopy-mode-vi WheelUpPane send -N"$scroll_speed_num_lines_per_scroll" -X scroll-up + tmux bind-key -Tcopy-mode-vi WheelDownPane send -N"$scroll_speed_num_lines_per_scroll" -X scroll-down + fi +} + +better_mouse_mode_main diff --git a/.tmux/plugins/tmux-better-mouse-mode/tests/basic_functionality_test.sh b/.tmux/plugins/tmux-better-mouse-mode/tests/basic_functionality_test.sh new file mode 100644 index 0000000..6e53097 --- /dev/null +++ b/.tmux/plugins/tmux-better-mouse-mode/tests/basic_functionality_test.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +# Setup +#tmux() { +# # Forward the "getter" calls to actual tmux, but change the setters to just +# # echo, so we can test what its setting. +# if [[ "$1" == "show-option" ]] ; then +# tmux-2.2/tmux "$@" +# else +# echo "$@" +# fi +#} +tmux() { + tmux-2.2/tmux "$@" +} +export -f tmux + +# ------ Unit Tests ----------------------- + + +testBasicBindKeysAreCalled() { + bash scroll_copy_mode.tmux + + assertNotNull "`tmux list-keys -T root | grep 'WheelUpPane'`" + assertNotNull "`tmux list-keys -T root | grep 'WheelDownPane'`" +} + +checkScrollSpeedSetCorrectly() { + testSpeed="$1" + expectedValue="$2" + tmux set -g @scroll-speed-num-lines-per-scroll $testSpeed + + bash scroll_copy_mode.tmux + + # Make sure send-keys shows up correct number of times in up and down scroll bindings. + assertEquals 'number of `send-keys` per scroll up not equal to user setting' $expectedValue `tmux list-keys -T root | grep 'WheelUpPane' | grep -o "'send-keys[^']*'" | head -n 1 | grep -o 'send-keys' | wc -l` + assertEquals 'number of `send-keys` per scroll down not equal to user setting' $expectedValue `tmux list-keys -T root | grep 'WheelDownPane' | grep -o "'send-keys[^']*'" | head -n 1 | grep -o 'send-keys' | wc -l` +} + +testValidIntegerScrollSpeeds() { + checkScrollSpeedSetCorrectly 1 1 + checkScrollSpeedSetCorrectly 2 2 + checkScrollSpeedSetCorrectly 10 10 + checkScrollSpeedSetCorrectly 0 0 + checkScrollSpeedSetCorrectly 2.5 2 +} + +testInvalidIntegerScrollSpeeds() { + checkScrollSpeedSetCorrectly "-1" 0 + checkScrollSpeedSetCorrectly "-10" 0 + checkScrollSpeedSetCorrectly "-0.1" 0 +} + +checkFractionalScrollSpeedSetCorrectly() { + testSpeed="$1" + expectedNumScrollsBeforeScroll="$2" + tmux set -g @scroll-speed-num-lines-per-scroll $testSpeed + + bash scroll_copy_mode.tmux + + assertNotNull "`tmux list-keys -T root | grep 'WheelUpPane' | grep \"only_scroll_sometimes.sh $expectedNumScrollsBeforeScroll\"`" + assertNotNull "`tmux list-keys -T root | grep 'WheelDownPane' | grep \"only_scroll_sometimes.sh $expectedNumScrollsBeforeScroll\"`" + + assertNotNull "`tmux show-environment __scroll_copy_mode__slow_scroll_count`" +} + +testValidFractionalScrollSpeeds() { + checkFractionalScrollSpeedSetCorrectly 0.5 2 + checkFractionalScrollSpeedSetCorrectly 0.25 4 + checkFractionalScrollSpeedSetCorrectly 0.33 3 +} + +# --------- Run tests command ------------- +. shunit2-2.1.6/src/shunit2 From 3233439d88547822be4e42a76e505b366062461d Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Wed, 19 Feb 2020 15:54:50 +0000 Subject: [PATCH 03/26] Update weathermap script for i3blocks display --- .local/bin/i3scripts/weathermap | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.local/bin/i3scripts/weathermap b/.local/bin/i3scripts/weathermap index 2ff240d..45810ea 100755 --- a/.local/bin/i3scripts/weathermap +++ b/.local/bin/i3scripts/weathermap @@ -85,12 +85,14 @@ if [ -n "$current" ] && [ -n "$forecast" ]; then now=$(date +%s) if [ "$sun_rise" -gt "$now" ]; then - daytime=" $(get_duration "$((sun_rise-now))")" # Sun rise + daytime=" $(get_duration "$((sun_rise-now))")" # Sun rise elif [ "$sun_set" -gt "$now" ]; then - daytime=" $(get_duration "$((sun_set-now))")" # Sun set + daytime=" $(get_duration "$((sun_set-now))")" # Sun set else - daytime=" $(get_duration "$((sun_rise-now))")" # Unknown + daytime=" $(get_duration "$((sun_rise-now))")" # Unknown fi - echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL $daytime" + + echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL $daytime" + #echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL $daytime" fi From 323662942043ac759c513c76218bfe8afbf5001a Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Wed, 19 Feb 2020 15:55:35 +0000 Subject: [PATCH 04/26] Add community scripts for i3blocks --- .local/bin/i3scripts/contrib/README.md | 18 +++++++ .local/bin/i3scripts/contrib/bandwidth | 35 ++++++++++++ .local/bin/i3scripts/contrib/battery | 42 +++++++++++++++ .local/bin/i3scripts/contrib/bauerbill | 44 +++++++++++++++ .local/bin/i3scripts/contrib/brightness | 26 +++++++++ .local/bin/i3scripts/contrib/cpu | 47 ++++++++++++++++ .local/bin/i3scripts/contrib/date | 13 +++++ .local/bin/i3scripts/contrib/disk | 68 +++++++++++++++++++++++ .local/bin/i3scripts/contrib/keyboard | 31 +++++++++++ .local/bin/i3scripts/contrib/memory | 46 ++++++++++++++++ .local/bin/i3scripts/contrib/mpc | 38 +++++++++++++ .local/bin/i3scripts/contrib/network | 36 +++++++++++++ .local/bin/i3scripts/contrib/pacman | 34 ++++++++++++ .local/bin/i3scripts/contrib/playerctl | 50 +++++++++++++++++ .local/bin/i3scripts/contrib/sound | 71 +++++++++++++++++++++++++ .local/bin/i3scripts/contrib/time | 13 +++++ .local/bin/i3scripts/contrib/util.sh | 41 ++++++++++++++ .local/bin/i3scripts/contrib/weather | 49 +++++++++++++++++ .local/bin/i3scripts/contrib/yaourt | 44 +++++++++++++++ 19 files changed, 746 insertions(+) create mode 100644 .local/bin/i3scripts/contrib/README.md create mode 100755 .local/bin/i3scripts/contrib/bandwidth create mode 100755 .local/bin/i3scripts/contrib/battery create mode 100755 .local/bin/i3scripts/contrib/bauerbill create mode 100755 .local/bin/i3scripts/contrib/brightness create mode 100755 .local/bin/i3scripts/contrib/cpu create mode 100755 .local/bin/i3scripts/contrib/date create mode 100755 .local/bin/i3scripts/contrib/disk create mode 100755 .local/bin/i3scripts/contrib/keyboard create mode 100755 .local/bin/i3scripts/contrib/memory create mode 100755 .local/bin/i3scripts/contrib/mpc create mode 100755 .local/bin/i3scripts/contrib/network create mode 100755 .local/bin/i3scripts/contrib/pacman create mode 100755 .local/bin/i3scripts/contrib/playerctl create mode 100755 .local/bin/i3scripts/contrib/sound create mode 100755 .local/bin/i3scripts/contrib/time create mode 100644 .local/bin/i3scripts/contrib/util.sh create mode 100755 .local/bin/i3scripts/contrib/weather create mode 100755 .local/bin/i3scripts/contrib/yaourt diff --git a/.local/bin/i3scripts/contrib/README.md b/.local/bin/i3scripts/contrib/README.md new file mode 100644 index 0000000..db97832 --- /dev/null +++ b/.local/bin/i3scripts/contrib/README.md @@ -0,0 +1,18 @@ +# i3-blocks-contrib + +A collection of useful blocks for [i3blocks](https://github.com/vivien/i3blocks), for the amazing [i3](https://i3wm.org) window manager. + + +## Configuration + +Some examples on how to configure these in your `i3blocks` config file: + +- @rosshadden's [i3blocks.conf](https://github.com/rosshadden/dotfiles/blob/master/src/.config/i3/i3blocks.conf) +- @oppenlander's [i3blocks.conf](https://github.com/oppenlander/dotfiles/blob/master/i3/i3blocks.conf) + + +## Contributing + +As hinted by the name, this is intended to be openly contributed to by the community. +There is no official contributing guide, but please try to fit in to the style and themes found in our existing blocks. +We use a somewhat ad-hock [YUIDoc](http://yui.github.io/yuidoc/) documentation syntax. diff --git a/.local/bin/i3scripts/contrib/bandwidth b/.local/bin/i3scripts/contrib/bandwidth new file mode 100755 index 0000000..87633d0 --- /dev/null +++ b/.local/bin/i3scripts/contrib/bandwidth @@ -0,0 +1,35 @@ +#!/bin/bash + +################################ +# Shows bandwidth +# +# @param {String(tx|rx)} type: The bandwidth type to check +# @return {Number(kB/s)}: Speed of the interface +################################ + +dir=$(dirname $0) +source $dir/util.sh + +type=$BLOCK_INSTANCE + +file=/tmp/i3blocks_bandwidth_$type +touch $file + +prev=$(cat $file) +cur=0 + +netdir=/sys/class/net +for iface in $(ls -1 $netdir); do + # Skip the loopback interface + if [ "$iface" == "lo" ]; then continue; fi + + f=$netdir/$iface/statistics/${type}_bytes + n=$(cat $f) + cur=$(expr $cur + $n) +done + +delta=$(calc "$cur - $prev") +echo "$(calc "$delta / 1000") kB/s" + +# store result +echo $cur > $file diff --git a/.local/bin/i3scripts/contrib/battery b/.local/bin/i3scripts/contrib/battery new file mode 100755 index 0000000..8781975 --- /dev/null +++ b/.local/bin/i3scripts/contrib/battery @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +################################ +# Shows info about connected batteries. +# +# Dependencies: +# - acpi +# +# @return {Number(%)}: Current battery charge +################################ + +dir=$(dirname $0) +source $dir/util.sh + +full="" +short="" +status=0 + +# Exit if no battery was found +if [ "$(acpi)" == "" ]; then exit 0; fi + +state=$(acpi | sed -n 's/Battery [0-9]: \([A-Z]\).*, .*/\1/p') +chg=$(acpi | sed -n 's/Battery [0-9]:.*, \([0-9]\{1,3\}\)%.*/\1/p') + +# Charging or Unknown +if [ $state = "C" ] || [ $state = "U" ]; then + icon="" +else + if [ $chg -le 10 ]; then + icon="" + status=33 + else + icon="" + fi +fi + +full="$icon $chg%" +short="$chg%" + +echo $full +echo $short +exit $status diff --git a/.local/bin/i3scripts/contrib/bauerbill b/.local/bin/i3scripts/contrib/bauerbill new file mode 100755 index 0000000..67c306a --- /dev/null +++ b/.local/bin/i3scripts/contrib/bauerbill @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +################################ +# Shows AUR packages that need updated. +# +# Dependencies: +# - checkupdates +# - bauerbill +# - [notify-send] +# +# @return {Number}: Outdated packages +################################ + +dir=$(dirname "$0") +source $dir/util.sh + +full="" +short="" +status=0 + +archPackages=$(checkupdates) +allPackages=$(bauerbill -Quq --aur) +numArchPackages=$(numLines "$archPackages") +numAllPackages=$(numLines "$allPackages") +numAurPackages=$(calc "$numAllPackages - $numArchPackages") + +if [ "$numAllPackages" -le "$numArchPackages" ]; then + numAurPackages=$numAllPackages +fi + +full=$numAurPackages +short=$full + +case $BLOCK_BUTTON in + # right click: show packages + 3) + aurPackages=$(diff -y <(echo "$archPackages") <(echo "$allPackages") | awk -p '{ print $3 }') + notify-send "AUR packages" "$aurPackages" + ;; +esac + +echo $full +echo $short +exit $status diff --git a/.local/bin/i3scripts/contrib/brightness b/.local/bin/i3scripts/contrib/brightness new file mode 100755 index 0000000..e5bb66c --- /dev/null +++ b/.local/bin/i3scripts/contrib/brightness @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +################################ +# Shows current brightness +# +# dependencies: +# - xbacklight +# +# @return {Number}: Current brightness +################################ + +case $BLOCK_BUTTON in + # right click + # set to `20 + 3) xbacklight -set 20 ;; + + # scroll up + # raise brightness + 4) xbacklight -inc 10 ;; + + # scroll down + # lower brightness + 5) xbacklight -dec 10 ;; +esac + +printf "%.0f" "$(xbacklight -get)" diff --git a/.local/bin/i3scripts/contrib/cpu b/.local/bin/i3scripts/contrib/cpu new file mode 100755 index 0000000..f86805a --- /dev/null +++ b/.local/bin/i3scripts/contrib/cpu @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +################################ +# Shows info about the CPU +# +# Dependencies: +# - [notify-send] +# +# @return {Number(%)}: CPU usage +################################ + +dir=$(dirname $0) +source $dir/util.sh + +full="" +short="" +status=0 + +read cpu a b c previdle rest < /proc/stat +prevtotal=$(calc "$a + $b + $c + $previdle") +sleep 0.5 +read cpu a b c idle rest < /proc/stat +total=$(calc "$a + $b + $c + $idle") + +CPU=$(calc "100 * (($total - $prevtotal) - ($idle - $previdle)) / ($total - $prevtotal)") + +full="$CPU%" +short=$full + +if [ $CPU -ge 90 ]; then + status=33 +fi + +case $BLOCK_BUTTON in + + # right click: show packages + 3) + n=16 + summary=$(ps -eo pcpu,pmem,pid,comm --sort=-pcpu | head -$n) + notify-send "Top $n CPU-eaters" "$summary" + ;; + +esac + +echo $full +echo $short +exit $status diff --git a/.local/bin/i3scripts/contrib/date b/.local/bin/i3scripts/contrib/date new file mode 100755 index 0000000..847004c --- /dev/null +++ b/.local/bin/i3scripts/contrib/date @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +################################ +# Shows current date +# +# @param {String} format: The format of the date +# @return {Date}: Current date +################################ + +format=${BLOCK_INSTANCE:-"%Y-%m-%d"} + +date +"$format" +date +"%m-%d" diff --git a/.local/bin/i3scripts/contrib/disk b/.local/bin/i3scripts/contrib/disk new file mode 100755 index 0000000..e71c968 --- /dev/null +++ b/.local/bin/i3scripts/contrib/disk @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +################################ +# Shows info about a specified mount point +# +# Dependencies: +# - [notify-send] +# +# @param {String} disk: The mount point to check +# @return {Number(%)}: Space used on the disk +################################ + +dir=$(dirname $0) +source $dir/util.sh + +full="" +short="" +status=0 + +disks=$(lsblk | tail -n +2 | awk '{ print $7 }' | sed '/^\s*$/d' | sort) +let numDisks=$(echo "$disks" | wc -l) +let diskNum=$(getCache 1) + +getDisk() { + echo "$disks" | sed -n "$diskNum p" +} +disk=$(getDisk) + +case $BLOCK_BUTTON in + # right click: show details + # TODO: fix + 3) + local summary=$(du -h --max-depth=1 $disk) + notify-send "Disk usage" "$summary" + ;; + # scroll up: cycle disks + 4) + diskNum=$[$(getCache) - 1] + if (( diskNum <= 0 )); then + diskNum=$numDisks + fi + setCache $diskNum + disk=$(getDisk) + ;; + 5) + # scroll down: cycle disks + diskNum=$[$(getCache) + 1] + if (( diskNum >= numDisks + 1 )); then + diskNum=1 + fi + setCache $diskNum + disk=$(getDisk) + ;; +esac + +usage=$(df -h $disk | sed -n '2 p') +usage=($usage) + +if [ ${usage[4]%?} -ge 90 ]; then + status=33 +fi + +full="$disk ${usage[4]}" +short="$full" + +echo $full +echo $short +exit $status diff --git a/.local/bin/i3scripts/contrib/keyboard b/.local/bin/i3scripts/contrib/keyboard new file mode 100755 index 0000000..2987a1b --- /dev/null +++ b/.local/bin/i3scripts/contrib/keyboard @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +################################ +# Shows current keyboard layout. +# Allows layout toggling. +# +# Dependencies: +# - [Ross' key script](https://github.com/rosshadden/dotfiles/blob/master/src/lib/keys.sh) +# +# @return {String}: Current keyboard layout +################################ + +keys=$HOME/bin/keys + +full="" +short="" +status=0 + +case $BLOCK_BUTTON in + # right click: toggle key variant + 3) $keys toggle ;; +esac + +layout=$($keys get) + +full=$layout +short=${layout:0:1} + +echo $full +echo $short +exit $status diff --git a/.local/bin/i3scripts/contrib/memory b/.local/bin/i3scripts/contrib/memory new file mode 100755 index 0000000..4db07d3 --- /dev/null +++ b/.local/bin/i3scripts/contrib/memory @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +################################ +# Shows info about the RAM +# +# Dependencies: +# - [notify-send] +# +# @return {Number(%)}: RAM usage +################################ + +dir=$(dirname $0) +source $dir/util.sh + +full="" +short="" +status=0 + +exec 6< /proc/meminfo +read a total b <&6 +read a free b <&6 +read a b c <&6 +read a buffer b <&6 +read a cached b <&6 + +MEM=$(calc "100 * ($total - ($free + $buffer + $cached)) / $total") + +full="$MEM%" +short=$full + +if [ $MEM -ge 80 ]; then + status=33 +fi + +case $BLOCK_BUTTON in + # right click: show packages + 3) + n=16 + summary=$(ps -eo pmem,pcpu,pid,comm --sort=-pmem | head -$n) + notify-send "Top $n RAM-eaters" "$summary" + ;; +esac + +echo $full +echo $short +exit $status diff --git a/.local/bin/i3scripts/contrib/mpc b/.local/bin/i3scripts/contrib/mpc new file mode 100755 index 0000000..6842dfd --- /dev/null +++ b/.local/bin/i3scripts/contrib/mpc @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +################################ +# Shows info from media players. +# +# Dependencies: +# - mpc +# +# @return {String}: Current media info +################################ + +full="" +short="" +status=0 + +format=${BLOCK_INSTANCE:-'[[%artist% - ]%title%[ \[%album%\]]]|[%file%]'} + +current=$(mpc current) +currentLong=$(mpc current -f "$format") +state=playing + +if [[ "$current" ]]; then + # Make icon mapping + declare -A icons + icons["playing"]="" + icons["paused"]="" + icons["stopped"]="" + + # Determine which icon to use + icon=${icons[$state]} + + full="$currentLong $icon" + short="$current $icon" +fi + +echo "$full" +echo "$short" +exit "$status" diff --git a/.local/bin/i3scripts/contrib/network b/.local/bin/i3scripts/contrib/network new file mode 100755 index 0000000..027e5a4 --- /dev/null +++ b/.local/bin/i3scripts/contrib/network @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +################################ +# Shows IP address of a given interface +# +# @param {String} interface: The network interface to check +# @return {String(IP)}: IP address of the interface +################################ + +dir=$(dirname $0) +source "$dir/util.sh" + +full="" +short="" +status=0 + +interface=${BLOCK_INSTANCE:-eth0} + +netPath=/sys/class/net +interfacePath=$(echo $netPath/$interface) +# Expand wildcard interfaces +interface=${interfacePath#$netPath/} + +state=$(cat $interfacePath/operstate) + +if [ $state == "up" ]; then + ips=$(ip addr show $interface | perl -n -e'/inet (.+)\// && print $1') + ip=${ips:-0.0.0.0} + + full=$ip + short=$full +fi + +echo "$full" +echo "$short" +exit $status diff --git a/.local/bin/i3scripts/contrib/pacman b/.local/bin/i3scripts/contrib/pacman new file mode 100755 index 0000000..daf2693 --- /dev/null +++ b/.local/bin/i3scripts/contrib/pacman @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +################################ +# Shows pacman packages that need updated. +# +# dependencies: +# - checkupdates +# - [notify-send] +# +# @return {Number}: Outdated packages +################################ + +dir=$(dirname "$0") +source $dir/util.sh + +full="" +short="" +status=0 + +packages=$(checkupdates) +numPackages=$(numLines "$packages") + +full=$numPackages +short=$full + +echo "$full" +echo "$short" + +case $BLOCK_BUTTON in + # right click: show packages + 3) notify-send "Pacman packages" "$packages" ;; +esac + +exit $status diff --git a/.local/bin/i3scripts/contrib/playerctl b/.local/bin/i3scripts/contrib/playerctl new file mode 100755 index 0000000..d135461 --- /dev/null +++ b/.local/bin/i3scripts/contrib/playerctl @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +################################ +# Shows info from media players. +# +# TODO: make output format configurable +# +# Dependencies: +# - playerctl +# +# @return {String}: Current media info +################################ + +dir=$(dirname $0) +source $dir/util.sh + +full="" +short="" +status=0 + +# Exit if no player found +players=$(playerctl -l) +if [[ ! $players ]]; then exit 0; fi + +artist=$(playerctl metadata artist) +title=$(playerctl metadata title) +album=$(playerctl metadata album) +state=$(playerctl status) + +if [[ "$title" ]]; then + # Make icon mapping + declare -A icons + icons["Playing"]="" + icons["Paused"]="" + icons["Stopped"]="" + + # Determine which icon to use + icon=${icons[$state]} + + full="$title" + if [[ "$artist" ]]; then full="$artist - $full"; fi + + short="$full $icon" + if [[ "$album" ]]; then full="$full [$album]"; fi + full="$full $icon" +fi + +echo $full +echo $short +exit $status diff --git a/.local/bin/i3scripts/contrib/sound b/.local/bin/i3scripts/contrib/sound new file mode 100755 index 0000000..70d2f86 --- /dev/null +++ b/.local/bin/i3scripts/contrib/sound @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +################################ +# Shows info about sound/volume. +# Allows simple volume controls. +# +# Thanks to [@EliteTK](https://gist.github.com/EliteTK/36d061fa24372fb70312), +# for the big speed gain when switching to `ponymix` +# +# Dependencies: +# - ponymix +# - ttf-font-icons +# +# @return {Number}: Current volume +################################ + +dir=$(dirname $0) +source $dir/util.sh + +full="" +short="" +status=0 + +step=${BLOCK_INSTANCE:-5} + +getVolume() { + ponymix get-volume +} + +isMuted() { + ponymix is-muted +} + +case $BLOCK_BUTTON in + # right click + # mute/unmute + 3) ponymix toggle >/dev/null ;; + + # scroll up + # raise volume + 4) ponymix increase $step >/dev/null ;; + + # scroll down + # lower volume + 5) ponymix decrease $step >/dev/null ;; +esac + +vol=$(getVolume) + +# level-based icon +if (( $vol == 0 )); then + icon="" +elif (( $vol < 34 )); then + icon="" +elif (( $vol < 67 )); then + icon="" +else + icon="" +fi + +# determine mute status +if isMuted; then + status=33 +fi + +full="$icon $vol%" +short=$vol + +echo $full +echo $short +exit $status diff --git a/.local/bin/i3scripts/contrib/time b/.local/bin/i3scripts/contrib/time new file mode 100755 index 0000000..24f78ab --- /dev/null +++ b/.local/bin/i3scripts/contrib/time @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +################################ +# Shows current time +# +# @param {String} format: The format of the time +# @return {Time}: Current time +################################ + +format=${BLOCK_INSTANCE:-"%H:%M:%S"} + +date +"$format" +date +"%H:%M" diff --git a/.local/bin/i3scripts/contrib/util.sh b/.local/bin/i3scripts/contrib/util.sh new file mode 100644 index 0000000..711b874 --- /dev/null +++ b/.local/bin/i3scripts/contrib/util.sh @@ -0,0 +1,41 @@ +################################ +# Calculates a given expression +# +# Dependencies: +# - bc +# +# @param {String} 1: The expression to calculate +# @return {Number}: The result of the expression +################################ +calc() { + echo "$1" | bc +} + +################################ +# Counts lines in text, accounting for empty values +# +# @param {String} 1: The input text +# @return {Number}: The number of lines +################################ +numLines() { + if [[ "$1" == "" ]]; then + echo 0 + else + echo "$1" | wc -l + fi +} + +cacheDir=".cache" +cacheFile="$cacheDir/i3-blocks-contrib-${BLOCK_NAME}" + +if [[ -z $cacheDir ]]; then + mkdir $cacheDir +fi + +getCache() { + cat $cacheFile || echo $1 +} + +setCache() { + echo "$1" > $cacheFile +} diff --git a/.local/bin/i3scripts/contrib/weather b/.local/bin/i3scripts/contrib/weather new file mode 100755 index 0000000..92f78c5 --- /dev/null +++ b/.local/bin/i3scripts/contrib/weather @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +################################ +# Shows info about the weather (in Cincinnati) from accuweather.com +# +# TODO: completely rewrite, probably using openweather APIs +# TODO: make location configurable +# TODO: make temperature unit configurable +# +# @return {Number(degrees Fahrenheit)}: Current temperature in Cincinnati +################################ + +dir=$(dirname $0) +source $dir/util.sh + +full="" +short="" +status=0 + +URL='http://www.accuweather.com/en/us/cincinnati-oh/45212/weather-forecast/350126' +SITE="$(curl -s "$URL")" + +weather="$(echo "$SITE" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $13 }'| head -1)" +temp="$(echo "$SITE" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $10 }'| head -1)" + +if [[ $weather == *thunder* || $weather == *Thunder* ]]; then + icon="" +else + if [[ $weather == *rain* || $weather == *Rain* ]]; then + icon="" + else + if [[ $weather == *snow* || $weather == *Snow* ]]; then + icon="❄" + else + if [[ $weather == *cloud* || $weather == *Cloud* ]]; then + icon="" + else + icon="" + fi + fi + fi +fi + +full="$icon $temp°" +short="$temp°" + +echo $full +echo $short +exit $status diff --git a/.local/bin/i3scripts/contrib/yaourt b/.local/bin/i3scripts/contrib/yaourt new file mode 100755 index 0000000..db92684 --- /dev/null +++ b/.local/bin/i3scripts/contrib/yaourt @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +################################ +# Shows AUR packages that need updated. +# +# Dependencies: +# - checkupdates +# - yaourt +# - [notify-send] +# +# @return {Number}: Outdated packages +################################ + +dir=$(dirname $0) +source $dir/util.sh + +full="" +short="" +status=0 + +archPackages=$(checkupdates) +allPackages=$(yaourt -Quaq) +numArchPackages=$(numLines "$archPackages") +numAllPackages=$(numLines "$allPackages") +numAurPackages=$(calc "$numAllPackages - $numArchPackages") + +if [ $numAllPackages -le $numArchPackages ]; then + numAurPackages=$numAllPackages +fi + +full=$numAurPackages +short=$full + +case $BLOCK_BUTTON in + # right click: show packages + 3) + aurPackages=$(diff -y <(echo "$archPackages") <(echo "$allPackages") | awk -p '{ print $3 }') + notify-send "AUR packages" "$aurPackages" + ;; +esac + +echo $full +echo $short +exit $status From a588c8d2168dd33c5933009b4945b7c5852b86d6 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sun, 23 Feb 2020 14:11:36 +0000 Subject: [PATCH 05/26] Add xfce4 power manager, wicd startup on i3 login --- .config/i3/config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.config/i3/config b/.config/i3/config index 71631c9..2b84eba 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -10,6 +10,8 @@ # Please see https://i3wm.org/docs/userguide.html for a complete reference! set $mod Mod4 +# Mod1 = Alt +#set $mod Mod1 focus_follows_mouse no for_window [class="yakuake"] floating enable @@ -224,6 +226,8 @@ exec --no-startup-id xbindkeys --poll-rc exec --no-startup-id $HOME/.local/bin/i3scripts/start_konky exec --no-startup-id sh ~/.fehbg exec --no-startup-id xautolock -time 10 -locker blurlock +exec --no-startup-id wicd-client -t +exec --no-startup-id xfce4-power-manager # Application keybinds From 59683479e5f95dd95bb3d02c876bef0de4ab821f Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sun, 23 Feb 2020 14:13:27 +0000 Subject: [PATCH 06/26] Update polybar for use on laptop --- .config/polybar/config | 17 +++++++++-------- .local/bin/i3scripts/info-idle | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.config/polybar/config b/.config/polybar/config index 7110528..2873291 100644 --- a/.config/polybar/config +++ b/.config/polybar/config @@ -54,7 +54,7 @@ padding-right = 6 module-margin-left = 4 module-margin-right = 6 -; Font ssettings, order matters +; Font settings, order matters ; Top font takes priority over following ;font-0 = Source Code Pro:size=10;0 font-0 = NotoSans-Regular:size=8;0 @@ -108,7 +108,7 @@ tail = true type = internal/fs ; Mountpoints to display mount-0 = / -mount-1 = /home +;mount-1 = /home ;mount-2 = /var ; Seconds to sleep between updates ; Default: 30 @@ -308,15 +308,16 @@ menu-0-4-exec = i3lock -c 000000 [module/caffeine] type = custom/menu format = -label-open = "  " -label-close = "  " +label-open = "  " +label-close = "  " label-open-padding = 0 label-close-padding = 1 label-separator = " " -menu-0-0 = " ﮣ " -menu-0-0-exec = source /home/kapper/.local/bin/i3scripts/xoffee enable -menu-0-1 = " ﮤ " -menu-0-1-exec = source /home/kapper/.local/bin/i3scripts/xoffee disable + +menu-0-0 = " ON " +menu-0-0-exec = sh /home/kapper/.local/bin/i3scripts/xoffee disable +menu-0-1 = " OFF " +menu-0-1-exec = sh /home/kapper/.local/bin/i3scripts/xoffee enable ; CPU Core Usages ;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/.local/bin/i3scripts/info-idle b/.local/bin/i3scripts/info-idle index ddfdf31..daeb370 100755 --- a/.local/bin/i3scripts/info-idle +++ b/.local/bin/i3scripts/info-idle @@ -1,6 +1,6 @@ #!/bin/bash ## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ## -## ## +## Depends on xprintidle package ## ## A script to track system idle time within a polybar menu ## ############################################################################### # info-idle.sh From ae88fd790afb35df929fd1d8f2ed6cc7de694adc Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sun, 23 Feb 2020 14:47:15 +0000 Subject: [PATCH 07/26] Add bindings for rofi launchers --- .config/i3/config | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.config/i3/config b/.config/i3/config index 2b84eba..78e7e63 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -57,6 +57,10 @@ bindsym $mod+Shift+q kill # start dmenu (a program launcher) bindsym $mod+d exec dmenu_run +bindsym $mod+x exec rofi -show run +bindsym $mod+a exec rofi -show window +bindsym $mod+z exec rofi -show ssh + # There also is the (new) i3-dmenu-desktop which only displays applications # shipping a .desktop file. It is a wrapper around dmenu, so you need that # installed. @@ -238,7 +242,7 @@ bindsym $mod+Return exec i3-sensible-terminal # Uses $TERMINAL environment setting # bindsym $mod+Return exec terminal # Open dropdown terminal using tilix quake mode -bindsym $mod+a exec tilix -q +bindsym $mod+t exec tilix -q # Firefox bindsym $mod+Shift+f exec firefox # Bluetooth device settings From 10807423120a5b94e37e666455bfb6fa1cb615d8 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Mon, 23 Mar 2020 19:52:33 -0400 Subject: [PATCH 08/26] Various updates for cleaner polybar on toshiba 2 chromebook --- .config/conky/sysinfo_green | 6 +-- .config/i3/config | 31 ++++++++----- .config/polybar/config | 67 ++++++++++++++++++----------- .local/bin/i3scripts/info-hackspeed | 3 +- .local/bin/i3scripts/info-idle | 2 +- .local/bin/i3scripts/weathermap | 11 ++--- 6 files changed, 74 insertions(+), 46 deletions(-) diff --git a/.config/conky/sysinfo_green b/.config/conky/sysinfo_green index a1e134c..c9e857a 100644 --- a/.config/conky/sysinfo_green +++ b/.config/conky/sysinfo_green @@ -35,17 +35,17 @@ ${voffset 3}$hr ${color2}${voffset 4}${alignr}${font Bitstream Vera Sans:size=10}RAM ${color} ${goto 0}${color2}$alignc${memgraph 40,305}${color} ${voffset 4}${goto 0}${alignc}${color2}${membar 10, 305} -${color}${goto 10}${font}${memperc}%${alignr}${exec grep -w Active: /proc/meminfo | awk '{print $2 / 1024 / 1024}'}/${memmax} +${color}${goto 10}${font}${memperc}%${alignr}${exec grep -w Active: /proc/meminfo | awk '{print $2 / 1024 }'}MiB /${memmax} ${voffset 3}${color}$hr # # CPU Display ${color2}${voffset 4}${alignr}${font Bitstream Vera Sans:size=10}CPU ${color} # Chipset ${alignr}${font}${exec inxi |grep CPU | awk '{print $4" "$2" "$3" "$6}'}${exec lscpu |grep -w "Model name:"| awk '{print " - " $8}'} -# CPU Grpah +# CPU Graph ${voffset 4}${goto 0}${alignc}${color2}${cpugraph 40, 305} # Percentage / GHz utilized -${voffset 0}${goto 10}${color}${font}${hwmon temp 1}F°${alignr}${cpu}% - ${freq_g}GHz +${voffset 0}${goto 10}${color}${font}${exec cat /sys/class/thermal/thermal_zone2/temp | awk '{print ( ( ( (9/5) * $1) / 1000) + 32) "°F" }'}${alignr}${cpu}% - ${freq_g}GHz # CPU Core Graphs ${voffset 10}${color}${goto 10}${font Bitstream Vera Sans:size=8}${cpu cpu1}%${goto 43}${color2}${cpubar cpu1 12,110} ${goto 170}${color}${cpu cpu2}%${goto 203}${color2}${cpubar cpu2 12,110} ${voffset 3}${color}$hr diff --git a/.config/i3/config b/.config/i3/config index 78e7e63..0a2b092 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -155,12 +155,12 @@ bindsym $mod+Shift+slash move container to workspace $ws96; workspace $ws96 bindsym $mod+Shift+period move container to workspace $ws95; workspace $ws95 bindsym $mod+Shift+comma move container to workspace $ws94; workspace $ws94 # Move to workspace -bindsym $mod+backslash workspace number $ws99 # Chat -bindsym $mod+bracketright workspace number $ws98 # Mail -bindsym $mod+apostrophe workspace number $ws97 # Sec -bindsym $mod+slash workspace number $ws96 # Web -bindsym $mod+period workspace number $ws95 # Terminal -bindsym $mod+comma workspace number $ws94 # Musak +bindsym $mod+backslash workspace number $ws99 +bindsym $mod+bracketright workspace number $ws98 +bindsym $mod+apostrophe workspace number $ws97 +bindsym $mod+slash workspace number $ws96 +bindsym $mod+period workspace number $ws95 +bindsym $mod+comma workspace number $ws94 # Switch to workspace @@ -206,6 +206,10 @@ for_window [class="Pavucontrol"] resize set height 400 for_window [class="Pavucontrol"] resize set width 600 for_window [class="Pavucontrol"] move position center +for_window [class="Yad"] floating enable +for_window [class="Yad"] resize set height 400 +for_window [class="Yad"] resize set width 600 + for_window [class="Bitwarden"] floating enable for_window [class="Bitwarden"] resize set height 600 for_window [class="Bitwarden"] resize set width 800 @@ -241,8 +245,9 @@ bindsym $mod+Return exec i3-sensible-terminal # start a terminal # Uses $TERMINAL environment setting # bindsym $mod+Return exec terminal -# Open dropdown terminal using tilix quake mode -bindsym $mod+t exec tilix -q +# Start / kill conky +bindsym $mod+t exec pkill compton +bindsym $mod+Shift+t exec compton # Firefox bindsym $mod+Shift+f exec firefox # Bluetooth device settings @@ -359,11 +364,15 @@ mode "resize" { bindsym $mod+r mode "resize" +# Use polybar installed +exec_always --no-startup-id /home/kapper/.config/polybar/start-polybar.sh +exec_always --no-startup-id compton # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) -bar { - status_command i3blocks -} +#bar { +# +# status_command i3blocks +#} # Theme colors # class border backgr. text indic. child_border diff --git a/.config/polybar/config b/.config/polybar/config index 2873291..05282f6 100644 --- a/.config/polybar/config +++ b/.config/polybar/config @@ -2,25 +2,29 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; [bar/top] - ; Polybar Position monitor = ${env:MONITOR} width = 100% -height = 34 +height = 30 ; Polybar Color -background = #000000 +; Depreciated.. +;tray-transparent = true +; Transparent adds 2 leading values to color (2+hex) +background = #00000000 +; Opaque is hex color (hex) foreground = #00c24a line-color = ${bar/bottom.background} line-size = 16 spacing = 2 +tray-background = #00111111 ; Polybar Padding padding-left = 0 padding-right = 5 ; Margin Between Modules -module-margin = 4 +module-margin = 2 ; Type font font-0 = NotoSans-Regular:size=8;0 @@ -30,14 +34,18 @@ font-2 = Noto Sans Mono:size=8;0 ; Modules modules-left = powermenu weather modules-center = ki3 -modules-right = info-hackspeed keyboard volume wired-network clock +modules-right = volume date + +; Set the cursor to display pointer / resize is interaction available +cursor-click = pointer +cursor-scroll = ns-resize [bar/bottom] ; Position, size of polybar monitor = ${env:MONITOR} bottom = true width = 100% -height = 27 +height = 20 ; Use top bar colors background = ${bar/top.background} @@ -51,8 +59,8 @@ padding-left = 6 padding-right = 6 ; Margins between modules -module-margin-left = 4 -module-margin-right = 6 +module-margin-left = 1 +module-margin-right = 2 ; Font settings, order matters ; Top font takes priority over following @@ -61,12 +69,14 @@ font-0 = NotoSans-Regular:size=8;0 font-1 = Inconsolata Nerd Font:size=12;0 font-2 = Noto Sans Mono:size=8;0 - ; Modules -modules-left = temp-cpu cpu +modules-left = temp-cpu cpu memfree memory modules-center = popup-utc network public-ip filesystem -modules-right = info-idle caffeine temp-gpu memory +modules-right = keyboard info-hackspeed info-idle +; Set the cursor to display pointer / resize is interaction available +cursor-click = pointer +cursor-scroll = ns-resize ; Modules ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -218,10 +228,10 @@ interval = 5.0 ; $ for i in /sys/class/hwmon/hwmon*/temp*_input; do echo "$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*})) $(readlink -f $i)"; done ; to find path to desired file ; Default reverts to thermal zone setting -exec = exec ~/.local/bin/i3scripts/cpusensor +exec = cat /sys/class/thermal/thermal_zone2/temp | awk '{print ( ( ( (9/5) * $1) / 1000) + 32) "°F" }' format =