-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 11e541f
Showing
16 changed files
with
432 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Force text files to have unix eols, so Windows/Cygwin does not break them | ||
*.* eol=lf | ||
*.png -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Changelog | ||
|
||
### v0.1.0, 2020-07-30 | ||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Sending PR's | ||
|
||
1. Fork repo | ||
2. Create your feature branch: `git checkout -b my-new-feature` | ||
3. Commit your changes: `git commit -am "Add some feature"` | ||
4. Push to the branch: `git push -u origin my-new-feature` | ||
5. Create new Pull Request | ||
|
||
## Submitting a Pull Request | ||
|
||
Please go through [existing issues](../../issues/) and [pull requests](../../pulls/) to check if somebody else is already working on the issue. | ||
|
||
#### Thank you for taking the time to contribute! 💙 💚 💛 💜 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Fedor Lukyanov | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Tmux Wifi Signal Strength | ||
|
||
Enables displaying transmit rate value and status icon in tmux status line. | ||
|
||
## TPM Installation | ||
|
||
Add plugin to the list of TPM plugins in `.tmux.conf`: | ||
|
||
``` | ||
set -g @plugin 'sleekybadger/tmux-wifi-signal-strength' | ||
``` | ||
|
||
Hit `prefix + I` to fetch the plugin and source it. | ||
|
||
If format strings are added to `status-left` or `status-right`, they should be visible now. | ||
|
||
## Manual Installation | ||
|
||
Clone the repo: | ||
|
||
``` | ||
$ git clone git@github.com:sleekybadger/tmux-wifi-signal-strength.git ~/clone/path | ||
``` | ||
|
||
Add this line to the bottom of `.tmux.conf`: | ||
|
||
``` | ||
run-shell ~/clone/path/wifi_signal_strength.tmux | ||
``` | ||
|
||
Reload TMUX environment: | ||
|
||
``` | ||
$ tmux source-file ~/.tmux.conf | ||
``` | ||
|
||
If format strings are added to `status-left` or `status-right`, they should now be visible. | ||
|
||
## Usage | ||
|
||
Add `#{wifi_signal_strength}`, `#{wifi_signal_strength_bg}` `#{wifi_signal_strength_fg}`, or | ||
`#{wifi_signal_strength_icon}` format strings to `status-left` or `status-right` tmux options. | ||
|
||
Example: | ||
|
||
``` | ||
set -g status-right "#{wifi_signal_strength_icon} #{wifi_signal_strength}" | ||
``` | ||
|
||
## Examples | ||
|
||
Signal strength low:<br /> | ||
![signal strength low](/screenshots/wifi_signal_strength_high.png) | ||
|
||
Signal strength medium:<br /> | ||
![signal strength medium](/screenshots/wifi_signal_strength_medium.png) | ||
|
||
Signal strength high:<br /> | ||
![signal strength high](/screenshots/wifi_signal_strength_low.png) | ||
|
||
Signal absent:<br /> | ||
![signal absent](/screenshots/wifi_signal_strength_off.png) | ||
|
||
This is done by introducing new format strings that can be added to status options: | ||
- `#{wifi_signal_strength}` - will display transmit rate value | ||
- `#{wifi_signal_strength_icon}` - will show a icon | ||
- `#{wifi_signal_strength_bg}` - will set the background color of the status bar based on the transmit rate value | ||
- `#{wifi_signal_strength_fg}` - will set the foreground color of the status bar based on the transmit rate value | ||
|
||
## Customization | ||
|
||
By default, these values are used: | ||
|
||
| Option | Value. | Description | | ||
| --------------------------------- | :-----------: | -------------------------------------------------------- | | ||
| @wifi_signal_strength_high_msg | #{rate} Mb/s | Used to display rate when rate >= 200 | | ||
| @wifi_signal_strength_medium_msg | #{rate} Mb/s | Used to display rate when rate >= 100 && rate < 200 | | ||
| @wifi_signal_strength_low_msg | #{rate} Mb/s | Used to display rate when rate > 0 && rate < 100 | | ||
| @wifi_signal_strength_off_msg | Off | Used to display rate when rate == 0 | | ||
| @wifi_signal_strength_high_bg | colour015 | Used for background color when rate >= 200 | | ||
| @wifi_signal_strength_medium_bg | colour015 | Used for background color when rate >= 100 && rate < 200 | | ||
| @wifi_signal_strength_low_bg | colour015 | Used for background color when rate > 0 && rate < 100 | | ||
| @wifi_signal_strength_off_bg | colour015 | Used for background color when rate == 0 | | ||
| @wifi_signal_strength_high_fg | colour034 | Used for foreground color when rate >= 200 | | ||
| @wifi_signal_strength_medium_fg | colour202 | Used for foreground color when rate >= 100 && rate < 200 | | ||
| @wifi_signal_strength_low_fg | colour196 | Used for foreground color when rate > 0 && rate < 100 | | ||
| @wifi_signal_strength_off_fg | colour000 | Used for foreground color when rate == 0 | | ||
| @wifi_signal_strength_high_icon | █ | Used for status icon when rate >= 200 | | ||
| @wifi_signal_strength_medium_icon | ▆ | Used for status icon when rate >= 100 && rate < 200 | | ||
| @wifi_signal_strength_low_icon | ▄ | Used for status icon when rate > 0 && rate < 100 | | ||
| @wifi_signal_strength_off_icon | | Used for status icon when rate == 0 | | ||
|
||
You can change these defaults by adding the following to `.tmux.conf`: | ||
|
||
``` | ||
set -g @wifi_signal_strength_high_msg "Hello world #{rate}" | ||
set -g @wifi_signal_strength_low_bg "colour000" | ||
set -g @wifi_signal_strength_medium_fg "colour201" | ||
set -g @wifi_signal_strength_off_icon "⮃" | ||
``` | ||
|
||
Don't forget to reload tmux environment after you do this: | ||
|
||
``` | ||
$ tmux source-file ~/.tmux.conf | ||
``` | ||
|
||
## History | ||
|
||
See [changelog](CHANGELOG.md). | ||
|
||
## Contributing | ||
|
||
See [contribution guidelines](CONTRIBUTING.md). | ||
|
||
## License | ||
|
||
Tmux Wifi Signal Strength is released under the [MIT](LICENSE.md) license. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
set_tmux_option() { | ||
local option="$1" | ||
local value="$2" | ||
|
||
echo "$option" | ||
echo "$value" | ||
|
||
tmux set-option -gqo "$option" "$value" | ||
} | ||
|
||
get_tmux_option() { | ||
local option="$1" | ||
local default_value="$2" | ||
|
||
local option_value="$(tmux show-option -gqv "$option")" | ||
if [ "$option_value" = "__wifi_signal_strength_default__" ]; then | ||
echo "$default_value" | ||
else | ||
echo "$option_value" | ||
fi | ||
} | ||
|
||
is_osx() { | ||
[ $(uname) == "Darwin" ] | ||
} | ||
|
||
get_tx_rate_from_airport() { | ||
local wireless_info="$(airport -I | grep "lastTxRate" | sed "s/.*: //")" | ||
|
||
if [ -z "$wireless_info" ]; then | ||
echo "0" | ||
else | ||
echo $wireless_info | ||
fi | ||
} | ||
|
||
get_tx_rate() { | ||
if is_osx; then | ||
get_tx_rate_from_airport | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
wifi_signal_strength_high_msg_option="@wifi_signal_strength_high_msg" | ||
wifi_signal_strength_high_msg_default="\#{rate} Mb/s" | ||
|
||
wifi_signal_strength_medium_msg_option="@wifi_signal_strength_medium_msg" | ||
wifi_signal_strength_medium_msg_default="\#{rate} Mb/s" | ||
|
||
wifi_signal_strength_low_msg_option="@wifi_signal_strength_low_msg" | ||
wifi_signal_strength_low_msg_default="\#{rate} Mb/s" | ||
|
||
wifi_signal_strength_off_msg_option="@wifi_signal_strength_off_msg" | ||
wifi_signal_strength_off_msg_default="Off" | ||
|
||
wifi_signal_strength_high_bg_option="@wifi_signal_strength_high_bg" | ||
wifi_signal_strength_high_bg_default="colour015" | ||
|
||
wifi_signal_strength_medium_bg_option="@wifi_signal_strength_medium_bg" | ||
wifi_signal_strength_medium_bg_default="colour015" | ||
|
||
wifi_signal_strength_low_bg_option="@wifi_signal_strength_low_bg" | ||
wifi_signal_strength_low_bg_default="colour015" | ||
|
||
wifi_signal_strength_off_bg_option="@wifi_signal_strength_off_bg" | ||
wifi_signal_strength_off_bg_default="colour015" | ||
|
||
wifi_signal_strength_high_fg_option="@wifi_signal_strength_high_fg" | ||
wifi_signal_strength_high_fg_default="colour034" | ||
|
||
wifi_signal_strength_medium_fg_option="@wifi_signal_strength_medium_fg" | ||
wifi_signal_strength_medium_fg_default="colour202" | ||
|
||
wifi_signal_strength_low_fg_option="@wifi_signal_strength_low_fg" | ||
wifi_signal_strength_low_fg_default="colour196" | ||
|
||
wifi_signal_strength_off_fg_option="@wifi_signal_strength_off_fg" | ||
wifi_signal_strength_off_fg_default="colour000" | ||
|
||
wifi_signal_strength_high_icon_option="@wifi_signal_strength_high_icon" | ||
wifi_signal_strength_high_icon_default="█" | ||
|
||
wifi_signal_strength_medium_icon_option="@wifi_signal_strength_medium_icon" | ||
wifi_signal_strength_medium_icon_default="▆" | ||
|
||
wifi_signal_strength_low_icon_option="@wifi_signal_strength_low_icon" | ||
wifi_signal_strength_low_icon_default="▄" | ||
|
||
wifi_signal_strength_off_icon_option="@wifi_signal_strength_off_icon" | ||
wifi_signal_strength_off_icon_default="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
source "$CURRENT_DIR/variables.sh" | ||
source "$CURRENT_DIR/helpers.sh" | ||
|
||
interpolate() { | ||
local message="$1" | ||
local value="$2" | ||
|
||
echo "${message//"\#{rate}"/$value}" | ||
} | ||
|
||
print_wifi_signal_strength() { | ||
local tx_rate="$(get_tx_rate)" | ||
local message | ||
|
||
if [ $tx_rate -gt 200 ]; then | ||
message="$(get_tmux_option "$wifi_signal_strength_high_msg_option" "$wifi_signal_strength_high_msg_default")" | ||
elif [ $tx_rate -gt 100 ]; then | ||
message="$(get_tmux_option "$wifi_signal_strength_medium_msg_option" "$wifi_signal_strength_medium_msg_default")" | ||
elif [ $tx_rate -gt 0 ]; then | ||
message="$(get_tmux_option "$wifi_signal_strength_low_msg_option" "$wifi_signal_strength_low_msg_default")" | ||
elif [ $tx_rate == 0 ]; then | ||
message="$(get_tmux_option "$wifi_signal_strength_off_msg_option" "$wifi_signal_strength_off_msg_default")" | ||
fi | ||
|
||
echo "$(interpolate "$message" "$tx_rate")" | ||
} | ||
|
||
main() { | ||
print_wifi_signal_strength | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
source "$CURRENT_DIR/variables.sh" | ||
source "$CURRENT_DIR/helpers.sh" | ||
|
||
print_wifi_signal_strength_bg() { | ||
local tx_rate="$(get_tx_rate)" | ||
|
||
if [ $tx_rate -gt 200 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_high_bg_option" "$wifi_signal_strength_high_bg_default") | ||
elif [ $tx_rate -gt 100 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_medium_bg_option" "$wifi_signal_strength_medium_bg_default") | ||
elif [ $tx_rate -gt 0 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_low_bg_option" "$wifi_signal_strength_low_bg_default") | ||
elif [ $tx_rate == 0 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_off_bg_option" "$wifi_signal_strength_off_bg_default") | ||
fi | ||
} | ||
|
||
main() { | ||
print_wifi_signal_strength_bg | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
source "$CURRENT_DIR/variables.sh" | ||
source "$CURRENT_DIR/helpers.sh" | ||
|
||
print_wifi_signal_strength_fg() { | ||
local tx_rate="$(get_tx_rate)" | ||
|
||
if [ $tx_rate -gt 200 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_high_fg_option" "$wifi_signal_strength_high_fg_default") | ||
elif [ $tx_rate -gt 100 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_medium_fg_option" "$wifi_signal_strength_medium_fg_default") | ||
elif [ $tx_rate -gt 0 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_low_fg_option" "$wifi_signal_strength_low_fg_default") | ||
elif [ $tx_rate == 0 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_off_fg_option" "$wifi_signal_strength_off_fg_default") | ||
fi | ||
} | ||
|
||
main() { | ||
print_wifi_signal_strength_fg | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
source "$CURRENT_DIR/variables.sh" | ||
source "$CURRENT_DIR/helpers.sh" | ||
|
||
print_wifi_signal_strength_icon() { | ||
local tx_rate="$(get_tx_rate)" | ||
|
||
if [ $tx_rate -gt 200 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_high_icon_option" "$wifi_signal_strength_high_icon_default") | ||
elif [ $tx_rate -gt 100 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_medium_icon_option" "$wifi_signal_strength_medium_icon_default") | ||
elif [ $tx_rate -gt 0 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_low_icon_option" "$wifi_signal_strength_low_icon_default") | ||
elif [ $tx_rate == 0 ]; then | ||
echo $(get_tmux_option "$wifi_signal_strength_off_icon_option" "$wifi_signal_strength_off_icon_default") | ||
fi | ||
} | ||
|
||
main() { | ||
print_wifi_signal_strength_icon | ||
} | ||
|
||
main |
Oops, something went wrong.