From b01252ad7696e1915ca5510b7da6481f760e2843 Mon Sep 17 00:00:00 2001 From: Von Random Date: Fri, 7 Oct 2016 14:20:45 +0300 Subject: [PATCH] i3 status and default $TERM for screen and tmux --- i3_config | 3 ++- i3_status | 34 ++++++++++++++++++++++++++++++ i3status.conf | 57 --------------------------------------------------- screenrc | 2 +- tmux.conf | 2 +- 5 files changed, 38 insertions(+), 60 deletions(-) create mode 100755 i3_status delete mode 100644 i3status.conf diff --git a/i3_config b/i3_config index 83340c9..09262bd 100644 --- a/i3_config +++ b/i3_config @@ -157,7 +157,8 @@ bindsym $mod+r mode "resize" # finds out, if available) bar { position top - status_command i3status + status_command /home/von/vdotfiles/i3_status + tray_output primary } new_window pixel 1 diff --git a/i3_status b/i3_status new file mode 100755 index 0000000..52353d8 --- /dev/null +++ b/i3_status @@ -0,0 +1,34 @@ +#!/usr/bin/python3 -u + +import time +import psutil + +def status_print(status_msg): + prefix = '[' + postfix = ']' + result = list() + for element in status_msg: + result.append('{"full_text":"' + element + '"}') + print(prefix + ','.join(result) + postfix) + +print('{"version":1}\n[') +while True: + values = list() + current_time = time.strftime('%a %d %H:%M') + values.append(current_time) + mem = psutil.virtual_memory() + memory = 'RAM: {}% ({:.3}G)'.format(100.0 - mem.percent, mem.available / 2**30) + values.append(memory) + with open('/sys/class/power_supply/BAT0/capacity', 'r') as capacity, open('/sys/class/power_supply/BAT0/status', 'r') as status: + batt_status = status.read().strip() + batt_capacity = capacity.read().strip() + if batt_status != 'Discharging': + batt_status = '↑' + else: + batt_status = '↓' + batt = 'BAT: ' + batt_capacity + '% ' + batt_status + values.append(batt) + values.reverse() + status_print(values) + time.sleep(5) + print(',', end='') diff --git a/i3status.conf b/i3status.conf deleted file mode 100644 index 5de5259..0000000 --- a/i3status.conf +++ /dev/null @@ -1,57 +0,0 @@ -# i3status configuration file. -# see "man i3status" for documentation. - -# It is important that this file is edited as UTF-8. -# The following line should contain a sharp s: -# ß -# If the above line is not correctly displayed, fix your editor first! - -general { - colors = true - interval = 5 -} - -#order += "ipv6" -order += "disk /" -#order += "run_watch DHCP" -#order += "run_watch VPN" -order += "wireless _first_" -order += "ethernet _first_" -order += "battery 0" -order += "load" -order += "tztime local" - -wireless _first_ { - format_up = "W: (%quality at %essid) %ip" - format_down = "W: down" -} - -ethernet _first_ { - # if you use %speed, i3status requires root privileges - format_up = "E: %ip (%speed)" - format_down = "E: down" -} - -battery 0 { - format = "%status %percentage %remaining" -} - -#run_watch DHCP { -# pidfile = "/var/run/dhclient*.pid" -#} - -#run_watch VPN { -# pidfile = "/var/run/vpnc/pid" -#} - -tztime local { - format = "%a %d %H:%M" -} - -load { - format = "%1min" -} - -disk "/" { - format = "%avail" -} diff --git a/screenrc b/screenrc index b26db02..b7f8bb4 100644 --- a/screenrc +++ b/screenrc @@ -10,7 +10,7 @@ defscrollback 10000 vbell off bell off autodetach on -term screen-256color +term screen altscreen on activity "activity on %n" caption always '%{=}%{RW} %H %{Yw} %S %{wd} %-w%{wk}[%t]%{wd}%+w' diff --git a/tmux.conf b/tmux.conf index cd1a84d..fe0169b 100644 --- a/tmux.conf +++ b/tmux.conf @@ -42,7 +42,7 @@ set -g set-titles "off" set -g status-left-length "20" set -g status-right-length "40" set -g terminal-override "rxvt-unicode*:sitm@,ritm@,xterm-*:Tc" -set -g default-terminal "screen-256color" +set -g default-terminal "screen" set -g status-position "bottom" set -g status-justify "centre" set -g status-left-length "100"