added weather script and tmux hook. Fixed submodules not updating correctly
This commit is contained in:
parent
1e6e5e32f9
commit
235cfce1d0
5
bin/tmux_mem_cpu_load.sh
Executable file
5
bin/tmux_mem_cpu_load.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd $HOME/.dotfiles/tmux/plugins/tmux-mem-cpu-load
|
||||||
|
cmake .
|
||||||
|
make
|
||||||
|
sudo make install
|
3
bin/weather/go.mod
Normal file
3
bin/weather/go.mod
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module weather
|
||||||
|
|
||||||
|
go 1.18
|
84
bin/weather/main.go
Normal file
84
bin/weather/main.go
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Weather struct {
|
||||||
|
Temp float64
|
||||||
|
Humidity int
|
||||||
|
Icon rune
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Weather) String() string {
|
||||||
|
return fmt.Sprintf("%c %.1f%cF %d%%", w.Icon, w.Temp, '\u00B0', w.Humidity) // Output as ICON ##.#*F ##% where the rune is a degree sign
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
weathercmd := exec.Command("sh", "-c", "${HOME}/.dotfiles/bin/weather/weather.sh")
|
||||||
|
var out bytes.Buffer
|
||||||
|
weathercmd.Stdout = &out
|
||||||
|
if err := weathercmd.Run(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
// parsing json time :D
|
||||||
|
var temp map[string]interface{}
|
||||||
|
if err := json.Unmarshal(out.Bytes(), &temp); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
// fmting hell
|
||||||
|
weather := &Weather{}
|
||||||
|
for k, v := range temp {
|
||||||
|
if k == "main" {
|
||||||
|
// weather info
|
||||||
|
for nk, nv := range v.(map[string]interface{}) {
|
||||||
|
if nk == "temp" {
|
||||||
|
weather.Temp = nv.(float64)
|
||||||
|
} else if nk == "humidity" {
|
||||||
|
weather.Humidity = int(nv.(float64)) // this is as gross as it gets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if k == "weather" {
|
||||||
|
m := v.([]interface{})
|
||||||
|
for nk, nv := range m[0].(map[string]interface{}) {
|
||||||
|
if nk == "icon" {
|
||||||
|
weather.Icon = getIcon(nv.(string))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Print(weather)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getIcon(code string) rune {
|
||||||
|
weather := strings.Trim(code, "nd") // trimming day or night tag
|
||||||
|
switch weather {
|
||||||
|
case "01":
|
||||||
|
// clear skys
|
||||||
|
return '\u263C' // sun code
|
||||||
|
case "02", "03":
|
||||||
|
// few clouds and scattered
|
||||||
|
return '\U0001F324' // small clouds with sun
|
||||||
|
case "04":
|
||||||
|
// broken clouds
|
||||||
|
return '\U0001F325' // big clouds with sun
|
||||||
|
case "09", "10":
|
||||||
|
// rain
|
||||||
|
return '\U0001F327' // cloud with rain
|
||||||
|
case "11":
|
||||||
|
// thunderstorm
|
||||||
|
return '\U0001F329' // thunderstorm cloud
|
||||||
|
case "13":
|
||||||
|
// snow
|
||||||
|
return '\U0001F328' // snow cloud
|
||||||
|
case "50":
|
||||||
|
// mist
|
||||||
|
return '\U0001F32B' // fog
|
||||||
|
default:
|
||||||
|
return '\uFFFD' // question mark
|
||||||
|
}
|
||||||
|
}
|
BIN
bin/weather/weather
Executable file
BIN
bin/weather/weather
Executable file
Binary file not shown.
12
bin/weather/weather.sh
Executable file
12
bin/weather/weather.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# if you get my email banned ill freak out
|
||||||
|
API_KEY='60844f78595f66ff8e94df50aed24397'
|
||||||
|
|
||||||
|
LOCATION=$(curl --silent http://ip-api.com/csv)
|
||||||
|
CITY=$(echo "$LOCATION" | cut -d , -f 6)
|
||||||
|
LAT=$(echo "$LOCATION" | cut -d , -f 8)
|
||||||
|
LON=$(echo "$LOCATION" | cut -d , -f 9)
|
||||||
|
# getting weather
|
||||||
|
WEATHER=$(curl --silent http://api.openweathermap.org/data/2.5/weather\?lat="$LAT"\&lon="$LON"\&appid="$API_KEY"\&units=imperial)
|
||||||
|
echo $WEATHER
|
@ -27,4 +27,4 @@
|
|||||||
- [cp ./vim/hybrid/colors/hybrid.vim ./vim/colors/hybrid.vim, Setting up theme]
|
- [cp ./vim/hybrid/colors/hybrid.vim ./vim/colors/hybrid.vim, Setting up theme]
|
||||||
- [tmux/plugins/tpm/bin/install_plugins, Installing Tmux Plugins]
|
- [tmux/plugins/tpm/bin/install_plugins, Installing Tmux Plugins]
|
||||||
- [tmux/plugins/tpm/bin/update_plugins all, Updating Tmux Plugins]
|
- [tmux/plugins/tpm/bin/update_plugins all, Updating Tmux Plugins]
|
||||||
|
- [bin/tmux_mem_cpu_build.sh, Building tmux-mem-cpu-load]
|
||||||
|
@ -7,8 +7,8 @@ set -g history-limit 10000
|
|||||||
# Set display time to be longer to allow selecting
|
# Set display time to be longer to allow selecting
|
||||||
set -g display-panes-time 5000
|
set -g display-panes-time 5000
|
||||||
|
|
||||||
# fix headless issue hopefully
|
# setup automatic renaming
|
||||||
set-window-option -g aggressive-resize
|
set -g automatic-rename on
|
||||||
|
|
||||||
# setting up TPM
|
# setting up TPM
|
||||||
set -g @plugin 'tmux-plugins/tpm'
|
set -g @plugin 'tmux-plugins/tpm'
|
||||||
@ -21,6 +21,8 @@ set -g @plugin 'thewtex/tmux-mem-cpu-load'
|
|||||||
set -g status-interval 1
|
set -g status-interval 1
|
||||||
set -g status-right "#[bg=black]#(~/.tmux/plugins/tmux-mem-cpu-load/tmux-mem-cpu-load -p -i 1 -a 1)#[default] %a %l:%M "
|
set -g status-right "#[bg=black]#(~/.tmux/plugins/tmux-mem-cpu-load/tmux-mem-cpu-load -p -i 1 -a 1)#[default] %a %l:%M "
|
||||||
set -g status-right-length 100
|
set -g status-right-length 100
|
||||||
|
set -g status-left "#(~/.dotfiles/bin/weather/weather)#[default] "
|
||||||
|
|
||||||
# tmux auto start
|
# tmux auto start
|
||||||
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
||||||
set -g @plugin 'tmux-plugins/tmux-continuum'
|
set -g @plugin 'tmux-plugins/tmux-continuum'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user