From dba767e8ff1599a0b4cf8fb3dc06ac0cce727748 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 6 Jan 2016 15:11:44 +0800 Subject: i3: update configuration for i3wm * Update i3 wm config * Add i3blocks.conf * Remove py3status --- .i3/config | 226 ++++++++++++++++------------- .i3/i3blocks.conf | 101 +++++++++++++ .i3/i3status.conf | 76 ++++++++++ .i3/py3status.conf | 78 ---------- .i3/py3status/10-mpd.py | 117 --------------- .i3/py3status/20-volume.py | 112 -------------- .i3/py3status/25-microphone.py | 105 -------------- .i3/py3status/30-touchpad.py | 86 ----------- .i3/py3status/40-power.py | 73 ---------- .i3/py3status/50-battery.py | 106 -------------- .i3/py3status/80-datetime.py | 76 ---------- .i3/py3status/backup/dpms.py | 44 ------ .i3/py3status/backup/empty_class.py | 41 ------ .i3/py3status/backup/glpi.py | 52 ------- .i3/py3status/backup/i3bar_click_events.py | 127 ---------------- .i3/py3status/backup/netdata.py | 132 ----------------- .i3/py3status/backup/ns_checker.py | 57 -------- .i3/py3status/backup/pingdom.py | 59 -------- .i3/py3status/backup/pomodoro.py | 123 ---------------- .i3/py3status/backup/sysdata.py | 137 ----------------- .i3/py3status/backup/weather_yahoo.py | 106 -------------- .i3/py3status/backup/whoami.py | 26 ---- 22 files changed, 302 insertions(+), 1758 deletions(-) create mode 100644 .i3/i3blocks.conf create mode 100644 .i3/i3status.conf delete mode 100644 .i3/py3status.conf delete mode 100644 .i3/py3status/10-mpd.py delete mode 100644 .i3/py3status/20-volume.py delete mode 100644 .i3/py3status/25-microphone.py delete mode 100644 .i3/py3status/30-touchpad.py delete mode 100644 .i3/py3status/40-power.py delete mode 100644 .i3/py3status/50-battery.py delete mode 100644 .i3/py3status/80-datetime.py delete mode 100644 .i3/py3status/backup/dpms.py delete mode 100644 .i3/py3status/backup/empty_class.py delete mode 100644 .i3/py3status/backup/glpi.py delete mode 100644 .i3/py3status/backup/i3bar_click_events.py delete mode 100644 .i3/py3status/backup/netdata.py delete mode 100644 .i3/py3status/backup/ns_checker.py delete mode 100644 .i3/py3status/backup/pingdom.py delete mode 100644 .i3/py3status/backup/pomodoro.py delete mode 100644 .i3/py3status/backup/sysdata.py delete mode 100644 .i3/py3status/backup/weather_yahoo.py delete mode 100644 .i3/py3status/backup/whoami.py diff --git a/.i3/config b/.i3/config index 3388538..1e274bb 100644 --- a/.i3/config +++ b/.i3/config @@ -2,10 +2,17 @@ ## ~/.i3/config ## ## i3 config file (v4) -## Ref: http://i3wm.org/docs/userguide.html ## -## Weitian LI -## 2014/05/10 +## References: +## [1] http://i3wm.org/docs/userguide.html +## +## Credits: +## [1] https://github.com/Airblader/dotfiles-manjaro +## [2] https://github.com/Remedan/dotfiles +## +## Aaron LI +## Created: 2014-05-10 +## Updated: 2015-12-18 ########################################################### ###### NOTES ###### {{{ @@ -34,7 +41,7 @@ set $shots_dir ~/pictures/screenshots # Use pango to choose FreeType fonts #font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 #font pango:DejaVu Sans Mono 10 -font pango:Terminus, WenQuanYi Bitmap Song, Icons, FontAwesome, 10 +font pango:Terminus, WenQuanYi Bitmap Song, FontAwesome, 10 # use `Mouse+$mod' to drag floating windows floating_modifier $mod @@ -45,6 +52,9 @@ floating_modifier $mod # timeout of urgency hint on workspace change (default 500ms) force_display_urgency_hint 1000 ms +# do not focus the activated window, always mark urgent (default: smart) +focus_on_window_activation urgent + # ipc (`i3-msg' to run i3 commands) ipc-socket ~/.i3/i3-ipc.sock ###### settings ###### }}} @@ -53,9 +63,12 @@ ipc-socket ~/.i3/i3-ipc.sock # border style #new_window 1pixel bindsym $mod+t border normal -bindsym $mod+y border 1pixel +bindsym $mod+y border pixel 3 bindsym $mod+u border none +# 2 pixel border by default +for_window [class="^.*"] border pixel 2 + # orientation for new workspaces default_orientation auto @@ -63,29 +76,44 @@ default_orientation auto #hide_edge_borders vertical ### colors -## solarized colorscheme (customized) {{{ -client.background #1e2320 -# colorclass border background text indicator -client.focused #859900 #859900 #fdf6e3 #2e9ef4 -client.focused_inactive #268bd2 #268bd2 #fdf6e3 #484e50 -client.unfocused #93a1a1 #93a1a1 #fdf6e3 #292d2e -client.urgent #cb4b16 #cb4b16 #fdf6e3 #2e9ef4 -## colorscheme }}} -# +# molokai +set $black #1b1d1e +set $white #f8f8f2 +set $dark_gray #303030 +set $light_gray #9999aa +set $red #b60050 +set $light_red #f92672 +set $green #88bb22 +set $light_green #80ff00 +set $brown #c47f2c +set $yellow #ffba68 +set $blue #30309b +set $light_blue #7070f0 +set $purple #7e40a5 +set $light_purple #bb88dd +set $cyan #4699af +set $light_cyan #66d9ef + +# BORDER BACKGROUND TEXT INDICATOR +client.focused $green $green $black $green +client.unfocused $black $black $white $black +client.focused_inactive $black $black $white $black +client.urgent $red $red $black $red +client.background $black ###### appearance ###### }}} ###### workspace ###### {{{ # name workspace -set $ws1 1gentoo -set $ws2 2term -set $ws3 3vim -set $ws4 4web -set $ws5 5work -set $ws6 6media -set $ws7 7game -set $ws8 8sys -set $ws9 9misc -set $ws0 0float +set $ws1 "1: " +set $ws2 "2: " +set $ws3 "3: " +set $ws4 "4: " +set $ws5 "5: ??" +set $ws6 "6: ??" +set $ws7 "7: " +set $ws8 "8:  " +set $ws9 "9: " +set $ws0 "10: " # switch to workspace bindsym $mod+1 workspace $ws1 @@ -98,6 +126,7 @@ bindsym $mod+7 workspace $ws7 bindsym $mod+8 workspace $ws8 bindsym $mod+9 workspace $ws9 bindsym $mod+0 workspace $ws0 + # auto back-and-forth when switched to the current workspace workspace_auto_back_and_forth yes @@ -115,11 +144,6 @@ bindsym $mod+Shift+0 move container to workspace $ws0 # move to provided workspace bindsym $mod+Shift+m exec i3-input -F 'move container to workspace "%s"' -P 'move to workspace: ' -# assign workspace for applications -assign [class="Gvim"] $ws3 -assign [class="Firefox" instance="Navigator"] $ws4 -assign [class="Vlc"] $ws6 - # switch workspace bindsym $mod+Tab workspace back_and_forth bindsym $mod+Ctrl+Left workspace prev @@ -138,34 +162,33 @@ bindsym $mod+Shift+q kill bindsym $mod+F4 kill # change focus (h/j/k/l) -bindsym $mod+h focus left -bindsym $mod+j focus down -bindsym $mod+k focus up -bindsym $mod+l focus right +bindsym $mod+h focus left +bindsym $mod+j focus down +bindsym $mod+k focus up +bindsym $mod+l focus right # alternatively, you can use the cursor keys: -bindsym $mod+Left focus left -bindsym $mod+Down focus down -bindsym $mod+Up focus up +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up bindsym $mod+Right focus right # move focused window (h/j/k/l) -bindsym $mod+Shift+h move left -bindsym $mod+Shift+j move down -bindsym $mod+Shift+k move up -bindsym $mod+Shift+l move right +bindsym $mod+Shift+h move left +bindsym $mod+Shift+j move down +bindsym $mod+Shift+k move up +bindsym $mod+Shift+l move right # alternatively, you can use the cursor keys: -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up bindsym $mod+Shift+Right move right # split in horizontal orientation bindsym $mod+Shift+v split h - # split in vertical orientation -bindsym $mod+v split v +bindsym $mod+v split v # enter fullscreen mode for the focused container bindsym $mod+f fullscreen @@ -194,6 +217,9 @@ bindsym $mod+Shift+minus move scratchpad # If there are multiple scratchpad windows, this command cycles through them. bindsym $mod+minus scratchpad show +# toggle whether to stick a window to the screen (regardless of workspaces) +bindsym $mod+Shift+s sticky toggle + # reload the configuration file bindsym $mod+Shift+c reload # restart i3 inplace (preserves layout/session, can be used to upgrade i3) @@ -226,12 +252,11 @@ mode "resize" { bindsym $mod+r mode "resize" # mode_system: prompt for lock, logout, suspend, shutdown, etc. -set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown +set $mode_system System (l) lock, (e) logout, (s) suspend, (r) reboot, (Shift+s) shutdown mode "$mode_system" { bindsym l exec --no-startup-id $i3_scripts/i3exit.sh lock, mode "default" bindsym e exec --no-startup-id $i3_scripts/i3exit.sh logout, mode "default" bindsym s exec --no-startup-id $i3_scripts/i3exit.sh suspend, mode "default" - bindsym h exec --no-startup-id $i3_scripts/i3exit.sh hibernate, mode "default" bindsym r exec --no-startup-id $i3_scripts/i3exit.sh reboot, mode "default" bindsym Shift+s exec --no-startup-id $i3_scripts/i3exit.sh shutdown, mode "default" # back to normal: Enter or Escape @@ -241,29 +266,34 @@ mode "$mode_system" { bindsym $mod+Ctrl+Delete mode "$mode_system" ###### i3 modes ###### }}} -###### applications bindings ###### {{{ +###### application bindings ###### {{{ ## NOTE: (Mod4: Win) ## Some Mod4-keys binded for urxvt (~/.Xresources) ## Mod4-c, Mod4-v, Mod4-Shift-v ## Mod4-Escape, Mode4-s, Mod4-u -# dmenu & i3-dmenu-desktop -bindsym $mod+d exec --no-startup-id dmenu_run -bindsym $mod+F2 exec --no-startup-id dmenu_run +## program launcher +#bindsym $mod+d exec --no-startup-id dmenu_run +#bindsym $mod+F2 exec --no-startup-id dmenu_run +# use 'rofi' instead of 'dmenu' +bindsym $mod+d exec --no-startup-id rofi -show run +bindsym $mod+F2 exec --no-startup-id rofi -show run # `i3-dmenu-desktop' only displays applications with a .desktop file -bindsym $mod+p exec --no-startup-id i3-dmenu-desktop +bindsym $mod+p exec --no-startup-id i3-dmenu-desktop # lock screen (i3lock) bindsym $mod+Ctrl+l exec --no-startup-id $i3_scripts/i3exit.sh lock +bindsym $sup+l exec --no-startup-id $i3_scripts/i3exit.sh lock # turn off display bindsym $mod+Ctrl+b exec --no-startup-id sleep 1 && xset dpms force off # screenshots -bindsym Print exec --no-startup-id scrot -e 'mv $f $shots_dir/$f' -bindsym $mod+Print exec --no-startup-id scrot -s -e 'mv $f $shots_dir/$f' +bindsym --release Print exec --no-startup-id scrot -e 'mv $f $shots_dir/' +bindsym --release $mod+Print exec --no-startup-id scrot -s -e 'mv $f $shots_dir/' # terminal -bindsym $sup+t exec urxvtc || urxvt || i3-sensible-terminal +bindsym $sup+t exec urxvtc || urxvt || i3-sensible-terminal +bindsym $sup+Enter exec urxvtc || urxvt || i3-sensible-terminal # file manager bindsym $sup+f exec thunar # web browser @@ -281,61 +311,53 @@ bindsym $mod+backslash [instance="dropdown_term"] scratchpad show ###### window control ###### {{{ ## floating -for_window [window_role="pop-up"] floating enable -for_window [class="Feh"] floating enable -for_window [class="XFontSel"] floating enable -for_window [class="Arandr"] floating enable -for_window [class="Xfce4-notifyd"] floating enable +for_window [window_role="pop-up"] floating enable +for_window [window_role="bubble"] floating enable +for_window [window_role="task_dialog"] floating enable +for_window [window_role="Preferences"] floating enable + +for_window [window_type="dialog"] floating enable +for_window [window_type="menu"] floating enable + +for_window [class="(?i)Arandr"] floating enable for_window [class="Xscreensaver-demo"] floating enable -for_window [class="Pinentry-gtk-2"] floating enable -for_window [class="Ds9"] floating enable -for_window [class="Toplevel"] floating enable -for_window [class="Firefox" instance="Places"] floating enable -for_window [class="Firefox" instance="Browser"] floating enable -for_window [class="Firefox" instance="Update"] floating enable -## floating by title -# xbindkeys + for_window [title="^XBindKey:.*Hit.*"] floating enable -# xev -for_window [title="^Event Tester$"] floating enable -# thunar copy files -for_window [title="^File Operation Progress$"] floating enable - -## adjust window border -for_window [class="URxvt"] border 1pixel -for_window [class="Firefox"] border 1pixel -for_window [class="Xfce4-notifyd"] border none + +for_window [class="(?i)Xfce4-notifyd"] floating enable, border none + +# assign workspace for applications +assign [class="(?i)firefox"] $ws1 ###### window control ###### }}} ###### i3bar ###### {{{ -# i3bar (plus the system information i3status finds out, if available) bar { - #status_command py3status -c ~/.i3/py3status.conf - status_command py3status -s -c ~/.i3/py3status.conf + #status_command i3status -c ~/.i3/i3status.conf + status_command i3blocks -c ~/.i3/i3blocks.conf position top # whether show the current binding mode indicator (default yes) #binding_mode_indicator no + font pango:Terminus, WenQuanYi Bitmap Song, FontAwesome, 11 + tray_output primary + separator_symbol " " + # disable scroll on workspace buttons + bindsym button4 nop + bindsym button5 nop + # disable tray padding (default: 2) + tray_padding 0 + # display workspace of name "[n]:[NAME]" with only the "[NAME]" + strip_workspace_numbers yes - ## color theme colors { - ## zenburn colorscheme (customized) {{{ - background #1e2320 - statusline #dcdccc - separator #94bff3 - # colorclass border background text - focused_workspace #506070 #506070 #ffffff - active_workspace #dcdccc #506070 #ffffff - inactive_workspace #dcdccc #1e2320 #dcdccc - urgent_workspace #dcdccc #cb4b16 #dcdccc - ## colorscheme }}} - # - ## solarized colorscheme {{{ - #background #073642 - #statusline #eee8d5 - #focused_workspace #cb4b16 #cb4b16 #eee8d5 - #active_workspace #cb4b16 #cb4b16 #eee8d5 - #inactive_workspace #b58900 #b58900 #eee8d5 - ## solarized }}} + statusline $white + background $black + separator $green + # BORDER BACKGROUND TEXT + focused_workspace $light_green $light_green $black + active_workspace $black $black $white + inactive_workspace $black $black $white + urgent_workspace $light_red $light_red $white + binding_mode $black $black $yellow } } ###### i3bar ###### }}} @@ -343,11 +365,13 @@ bar { ###### autostart ###### {{{ ## run applications on startup ## if need to run command when restarting i3, use `exec_always' -# disable bell exec --no-startup-id xset b off exec --no-startup-id xrdb -load ~/.Xresources +#exec --no-startup-id feh --bg-fill $i3_images/wallpaper.png exec --no-startup-id sh ~/.fehbg -exec --no-startup-id xcompmgr +#exec --no-startup-id xcompmgr +exec --no-startup-id compton -b +exec --no-startup-id redshift exec --no-startup-id xbindkeys exec --no-startup-id urxvtd -q -o -f exec --no-startup-id parcellite diff --git a/.i3/i3blocks.conf b/.i3/i3blocks.conf new file mode 100644 index 0000000..28b79a6 --- /dev/null +++ b/.i3/i3blocks.conf @@ -0,0 +1,101 @@ +# +# i3blocks config file +# +# Aaron LI +# 2015-12-18 +# + + +# List of valid properties: +# +# align +# color +# command +# full_text +# instance +# interval +# label +# min_width +# name +# separator +# separator_block_width +# short_text +# signal +# urgent + +# Global properties +# +# The top properties below are applied to every block, but can be overridden. +# Each block command defaults to the script name to avoid boilerplate. +command=$SCRIPT_DIR/$BLOCK_NAME +separator_block_width=15 +markup=none + +# Volume indicator +# +# The first parameter sets the step (and units to display) +# The second parameter overrides the mixer selection +# See the script for details. +[volume] +label=VOL +#label=♪ +instance=Master +#instance=PCM +interval=once +signal=10 + +# Memory usage +# +# The type defaults to "mem" if the instance is not specified. +[memory] +label=MEM +separator=false +interval=30 + +# Network interface monitoring +# +# If the instance is not specified, use the interface used for default route. +# The address can be forced to IPv4 or IPv6 with -4 or -6 switches. +[iface] +#instance=wlan0 +color=#00FF00 +interval=10 +separator=false + +[wifi] +#instance=wlp3s0 +interval=10 +separator=false + +[bandwidth] +#instance=eth0 +interval=5 + +# CPU usage +# +# The script may be called with -w and -c switches to specify thresholds, +# see the script for details. +[cpu_usage] +label=CPU +interval=10 +min_width=CPU: 100.00% +#separator=false + +#[load_average] +#interval=10 + +# Battery indicator +# +# The battery instance defaults to 0. +[battery] +label=BAT +#label=⚡ +#instance=1 +interval=30 + +# Date Time +# +[time] +command=date '+%Y-%m-%d %H:%M:%S' +interval=5 + diff --git a/.i3/i3status.conf b/.i3/i3status.conf new file mode 100644 index 0000000..9a41923 --- /dev/null +++ b/.i3/i3status.conf @@ -0,0 +1,76 @@ +# ~/.i3status.conf +# 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 + color_good = '#88b090' + color_degraded = '#ccdc90' + color_bad = '#e89393' + interval = 3 + # output format (i3bar|dzen2|xmobar|none) + output_format = 'i3bar' +} + +order += "volume master" +#order += "ipv6" +order += "disk /" +#order += "run_watch DHCP" +#order += "run_watch VPN" +#order += "wireless wlp3s0" +order += "ethernet eth0" +order += "battery 0" +order += "load" +order += "tztime local" + +volume master { + format = "%volume" + device = "default" + mixer = "Master" + mixer_idx = 0 +} + +#wireless wlp3s0 { +# #format_up = "W: (%quality at %essid) %ip" +# format_up = "%essid(%ip)" +# format_down = "down" +#} + +ethernet eth0 { + # if you use %speed, i3status requires root privileges + format_up = "E: %ip" + format_down = "E: down" +} + +battery 0 { + format = "%status %percentage %remaining" +} + +run_watch DHCP { + #pidfile = "/var/run/dhclient*.pid" + pidfile = "/var/run/dhcpd*.pid" +} + +run_watch VPN { + pidfile = "/var/run/vpnc/pid" +} + +tztime local { + #format = "%Y-%m-%d %H:%M:%S" + format = "%m-%d|%H:%M" +} + +load { + format = "%1min" +} + +disk "/" { + format = "%free" +} + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=conf: # diff --git a/.i3/py3status.conf b/.i3/py3status.conf deleted file mode 100644 index d19b4b8..0000000 --- a/.i3/py3status.conf +++ /dev/null @@ -1,78 +0,0 @@ -## ~/.i3/py3status.conf -## -## py3status configuration file -## same syntax as 'i3status.conf' (man i3status) -## - -# 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 - color_good = '#dcdccc' - color_degraded = '#8cd0d3' - color_bad = '#dc8cc3' - interval = 3 - # output format (i3bar|dzen2|xmobar|none) - output_format = 'i3bar' -} - -#order += "volume master" -#order += "ipv6" -#order += "disk /" -#order += "run_watch DHCP" -#order += "run_watch VPN" -#order += "wireless wlp3s0" -#order += "ethernet enp0s25" -order += "battery 0" -order += "load" -#order += "tztime local" - -volume master { - format = "%volume" - device = "default" - mixer = "Master" - mixer_idx = 0 -} - -wireless wlp3s0 { - #format_up = "W: (%quality at %essid) %ip" - format_up = "%essid(%ip)" - format_down = "down" -} - -ethernet enp0s25 { - # if you use %speed, i3status requires root privileges - format_up = "E: %ip" - format_down = "E: down" -} - -battery 0 { - format = "%status %percentage %remaining" -} - -run_watch DHCP { - #pidfile = "/var/run/dhclient*.pid" - pidfile = "/var/run/dhcpd*.pid" -} - -run_watch VPN { - pidfile = "/var/run/vpnc/pid" -} - -tztime local { - #format = "%Y-%m-%d %H:%M:%S" - format = "%m-%d|%H:%M" -} - -load { - format = "%1min" -} - -disk "/" { - format = "%free" -} - -# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=conf: # diff --git a/.i3/py3status/10-mpd.py b/.i3/py3status/10-mpd.py deleted file mode 100644 index 95b7b4f..0000000 --- a/.i3/py3status/10-mpd.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Weitian LI -# 2014/05/14 - -""" -mpd module for py3status -""" - -## Get output of shell command: -## python 3.x: -## >>> subprocess.getoutput(cmd) -## >>> subprocess.getstatusoutput(cmd) -## python 2.7.x: -## >>> subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) - -import os -import re -import subprocess -import time - - -POSITION = 0 -# regex to match the status string of 'mpc status' output -mpd_status_p = re.compile(r'.*\n^\[([a-z]+)\]', re.M) # multiline - -class Py3status: - """ - MPD module to show mpd status and play info. - - This module also handle click events: - left button: mpc toggle - middle button: mpc stop - right button: mpc next - """ - - def mpd(self, i3status_output_json, i3status_config): - """ - Display MPD status and song info. - """ - response = { - 'full_text': '', - 'name': 'mpd', - 'instance': 'first', - } - # update response fields - self._update_response(i3status_config) - if self.color: - response['color'] = self.color - response['full_text'] = self.full_text - # cache status for 5 seconds - response['cached_until'] = time.time() + 5 - return (POSITION, response) - - def on_click(self, i3status_output_json, i3status_config, event): - """ - Handle click events. - """ - if event['button'] == 1: - # left button click - cmd = 'mpc toggle' - cmd_output = subprocess.getoutput(cmd) - elif event['button'] == 2: - # middle button click - cmd = 'mpc stop' - cmd_output = subprocess.getoutput(cmd) - elif event['button'] == 3: - # right button click - cmd = 'mpc next' - cmd_output = subprocess.getoutput(cmd) - # - self._update_response(i3status_config) - os.system('killall -USR1 py3status') - - def _update_response(self, i3status_config=None): - ## get mpd status - cmd = 'mpc status' - cmd_out = subprocess.getstatusoutput(cmd) - if cmd_out[0] == 0: - # mpd is running - mpd_status_m = mpd_status_p.match(cmd_out[1]) - if mpd_status_m: - self.status = mpd_status_m.group(1) - else: - self.status = 'stopped' - else: - # mpd not running (N/A) - self.status = 'na' - ## set full_text and color - prompt = '' # Icons: uF198 (music) - if self.status == 'playing': - status_text = ' ' # Icons: uF04B (play) - cmd = 'mpc status -f "%artist%-%title%" | head -n 1' - song_text = subprocess.getoutput(cmd) - if i3status_config: - self.color = i3status_config['color_good'] - elif self.status == 'paused': - status_text = ' ' # Icons: uF04C (pause) - cmd = 'mpc status -f "%title%" | head -n 1' - song_text = subprocess.getoutput(cmd) - if i3status_config: - self.color = i3status_config['color_degraded'] - elif self.status == 'stopped': - status_text = '' # Icons: uF04D (stop) - song_text = '' - if i3status_config: - self.color = i3status_config['color_bad'] - else: - # mpd not running (N/A) - status_text = '' # Icons: uF00D (X) - song_text = '' - if i3status_config: - self.color = i3status_config['color_bad'] - # full_text - self.full_text = '{0} {1}{2}'.format(prompt, status_text, song_text) - diff --git a/.i3/py3status/20-volume.py b/.i3/py3status/20-volume.py deleted file mode 100644 index 467764c..0000000 --- a/.i3/py3status/20-volume.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Weitian LI -# 2014/05/15 - -""" -volume module for py3status -""" - -## Get output of shell command: -## python 3.x: -## >>> subprocess.getoutput(cmd) -## >>> subprocess.getstatusoutput(cmd) -## python 2.7.x: -## >>> subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) - -import os -import re -import subprocess -import time - - -POSITION = 0 -DEVICE = 'default' -MIXER = 'Master' -# regex compile to match amixer output volume info -amixer_rep = re.compile(r'.*\[(\d+)%\]\s*\[(on|off)\]') - - -class Py3status: - """ - Volume module to show volume info. - - This module also handle click events: - left button: decrease volume - middle button: mute/unmute toggle - right button: increase volume - """ - - def myvolume(self, i3status_output_json, i3status_config): - """ - Display volume info. - - XXX: cannot use name 'volume' ?? - """ - response = { - 'full_text': '', - 'name': 'myvolume', - 'instance': 'first', - } - # update response fields - self._update_response(i3status_config) - if self.color: - response['color'] = self.color - response['full_text'] = self.full_text - # cache status for 5 seconds - response['cached_until'] = time.time() + 5 - return (POSITION, response) - - def on_click(self, i3status_output_json, i3status_config, event): - """ - Handle click events. - """ - if event['button'] == 1: - # left button click - cmd = 'amixer -D "{0}" sset "{1}" "5%-" unmute'.format(DEVICE, MIXER) - cmd_output = subprocess.getoutput(cmd) - elif event['button'] == 2: - # middle button click - cmd = 'amixer -D "{0}" sset "{1}" toggle'.format(DEVICE, MIXER) - cmd_output = subprocess.getoutput(cmd) - elif event['button'] == 3: - # right button click - cmd = 'amixer -D "{0}" sset "{1}" "5%+" unmute'.format(DEVICE, MIXER) - cmd_output = subprocess.getoutput(cmd) - # - self._update_response(i3status_config) - os.system('killall -USR1 py3status') - - def _update_response(self, i3status_config=None): - """ - update self.full_text - """ - # get volume info - cmd = 'amixer -D "{0}" sget "{1}" | tail -n 1'.format(DEVICE, MIXER) - cmd_output = subprocess.getoutput(cmd) - m = amixer_rep.match(cmd_output) - self.volume, self.status = m.group(1, 2) - if int(self.volume) > 60: - self.level = 'high' - prompt = '' # Icons: uF357 (volume-high) - if i3status_config: - self.color = i3status_config['color_degraded'] - elif int(self.volume) > 30: - self.level = 'medium' - prompt = '' # Icons: uF359 (volume-medium) - if i3status_config: - self.color = i3status_config['color_good'] - else: - self.level = 'low' - prompt = '' # Icons: uF358 (volume-low) - if i3status_config: - self.color = i3status_config['color_good'] - # determine icon - if self.status == 'off': - prompt = '' # Icons: uF35A (volume-off) - if i3status_config: - self.color = i3status_config['color_bad'] - # determine display info - self.full_text = '{0} {1}%'.format(prompt, self.volume) - diff --git a/.i3/py3status/25-microphone.py b/.i3/py3status/25-microphone.py deleted file mode 100644 index 379a44c..0000000 --- a/.i3/py3status/25-microphone.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Weitian LI -# 2014/05/15 - -""" -microphone module for py3status -""" - -## Get output of shell command: -## python 3.x: -## >>> subprocess.getoutput(cmd) -## >>> subprocess.getstatusoutput(cmd) -## python 2.7.x: -## >>> subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) - -import os -import re -import subprocess - - -POSITION = 0 -DEVICE = 'default' -MIXER = 'Capture' # Microphone -# regex compile to match amixer output volume info -amixer_rep = re.compile(r'.*\[(\d+)%\]\s*\[(on|off)\]') - - -class Py3status: - """ - Microphone module to show microphone info. - - This module also handle click events: - left button: decrease volume - middle button: mute/unmute toggle - right button: increase volume - """ - - def microphone(self, i3status_output_json, i3status_config): - """ - Display microphone info. - """ - response = { - 'full_text': '', - 'name': 'microphone', - 'instance': 'first', - } - # update response fields - self._update_response(i3status_config) - response['full_text'] = self.full_text - if self.color: - response['color'] = self.color - return (POSITION, response) - - def on_click(self, i3status_output_json, i3status_config, event): - """ - Handle click events. - """ - if event['button'] == 1: - # left button click - cmd = 'amixer -D "{0}" sset "{1}" "5%-" unmute'.format(DEVICE, MIXER) - cmd_output = subprocess.getoutput(cmd) - elif event['button'] == 2: - # middle button click - cmd = 'amixer -D "{0}" sset "{1}" toggle'.format(DEVICE, MIXER) - cmd_output = subprocess.getoutput(cmd) - elif event['button'] == 3: - # right button click - cmd = 'amixer -D "{0}" sset "{1}" "5%+" unmute'.format(DEVICE, MIXER) - cmd_output = subprocess.getoutput(cmd) - # - self._update_response(i3status_config) - os.system('killall -USR1 py3status') - - def _update_response(self, i3status_config=None): - """ - update self.full_text - """ - # get volume info - cmd = 'amixer -D "{0}" sget "{1}" | tail -n 1'.format(DEVICE, MIXER) - cmd_output = subprocess.getoutput(cmd) - m = amixer_rep.match(cmd_output) - self.volume, self.status = m.group(1, 2) - prompt = '' # Icons: uF130 (mic-on) - if int(self.volume) > 60: - self.level = 'high' - if i3status_config: - self.color = i3status_config['color_degraded'] - elif int(self.volume) > 30: - self.level = 'medium' - if i3status_config: - self.color = i3status_config['color_good'] - else: - self.level = 'low' - if i3status_config: - self.color = i3status_config['color_good'] - # determine icon - if self.status == 'off': - prompt = '' # Icons: uF131 (mic-off) - if i3status_config: - self.color = i3status_config['color_bad'] - # determine display info - self.full_text = '{0} {1}%'.format(prompt, self.volume) - diff --git a/.i3/py3status/30-touchpad.py b/.i3/py3status/30-touchpad.py deleted file mode 100644 index 195d6b1..0000000 --- a/.i3/py3status/30-touchpad.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Weitian LI -# 2014/05/15 - -""" -touchpad module for py3status -""" - -## Get output of shell command: -## python 3.x: -## >>> subprocess.getoutput(cmd) -## >>> subprocess.getstatusoutput(cmd) -## python 2.7.x: -## >>> subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) - -import os -import re -import subprocess - - -POSITION = 0 - - -class Py3status: - """ - Touchpad module to show the status of touchpad. - - Click events: - left button: enable touchpad - middle button: toggle touchpad - """ - - def __init__(self): - """ - get touchpad status - """ - cmd = 'synclient -l | grep -c "TouchpadOff.*=.*0"' - touchpad_status = subprocess.getoutput(cmd) - if int(touchpad_status) == 1: - self.status = 'on' - else: - self.status = 'off' - - def touchpad(self, i3status_output_json, i3status_config): - """ - Display touchpad status. - """ - #prompt = '' # Icons: uF10A (ipad) - prompt = '' # Icons: uF3E3 (palm) - response = { - 'full_text': '', - 'name': 'touchpad', - 'instance': 'first', - } - if self.status == 'on': - response['color'] = i3status_config['color_good'] - status_text = '' # Icons: uF00C (check) - else: - response['color'] = i3status_config['color_bad'] - status_text = '' # Icons: uF00D (cross) - response['full_text'] = '{0} {1}'.format(prompt, status_text) - return (POSITION, response) - - def on_click(self, i3status_output_json, i3status_config, event): - """ - Handle click events. - """ - if event['button'] == 1: - # left button click - cmd = 'synclient TouchpadOff=0' - cmd_output = subprocess.getoutput(cmd) - self.status = 'on' - elif event['button'] == 2: - # middle button click - if self.status == 'on': - cmd = 'synclient TouchpadOff=1' - self.status = 'off' - else: - cmd = 'synclient TouchpadOff=0' - self.status = 'on' - cmd_output = subprocess.getoutput(cmd) - # - os.system('killall -USR1 py3status') - diff --git a/.i3/py3status/40-power.py b/.i3/py3status/40-power.py deleted file mode 100644 index 96b8ce5..0000000 --- a/.i3/py3status/40-power.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Weitian LI -# 2014/05/15 - -""" -power module for py3status -""" - -## Get output of shell command: -## python 3.x: -## >>> subprocess.getoutput(cmd) -## >>> subprocess.getstatusoutput(cmd) -## python 2.7.x: -## >>> subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) - -import re -import subprocess -import time - - -POSITION = 0 - -BAT_PRESENT = '/sys/class/power_supply/BAT0/present' -# regex to match the '1' at the beginning -one_p = re.compile(r'(^1).*') - - -class Py3status: - """ - Power module to show whether AC/battery is online. - - ac_status: online, offline - bat_status: present, na - """ - - def power(self, i3status_output_json, i3status_config): - """ - Display power status. - """ - response = { - 'full_text': '', - 'name': 'power', - 'instance': 'first', - } - # AC online - ac_cmd = 'on_ac_power' - ac_cmd_out = subprocess.getstatusoutput(ac_cmd) - if ac_cmd_out[0] == 0: - ac_text = '' # Icons: uF237 (ac-online) - self.ac_status = 'online' - response['color'] = i3status_config['color_good'] - else: - ac_text = '' # Icons: uF236 (ac-offline) - self.ac_status = 'offline' - response['color'] = i3status_config['color_bad'] - # Battery present - with open(BAT_PRESENT, 'r') as bat_present_f: - bat_present_c = bat_present_f.read() - bat_m = one_p.match(bat_present_c) - if bat_m.group(1): - bat_text = ' ' # Icons: uF3CF (battery-vertical) - self.bat_status = 'present' - else: - bat_text = '' - self.bat_status = 'na' - # - response['full_text'] = '{0} {1}'.format(ac_text, bat_text) - # cache status for 5 seconds - response['cached_until'] = time.time() + 5 - return (POSITION, response) - diff --git a/.i3/py3status/50-battery.py b/.i3/py3status/50-battery.py deleted file mode 100644 index 5e88125..0000000 --- a/.i3/py3status/50-battery.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Weitian LI -# 2014/05/17 - -""" -battery module for py3status -""" - -## Get output of shell command: -## python 3.x: -## >>> subprocess.getoutput(cmd) -## >>> subprocess.getstatusoutput(cmd) -## python 2.7.x: -## >>> subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) - -import re -import subprocess -import time - - -POSITION = 0 - -BAT_ID = 0 -## uevent: -## ENERGY_NOW: energy that battery has now -## POWER_NOW: battery current discharging/charing rate -BAT_UEVENT = '/sys/class/power_supply/BAT{0}/uevent'.format(BAT_ID) - -# regex to match pattern in 'uevent' contents' -status_p = re.compile(r'.*STATUS=(\w+)', re.S) -present_p = re.compile(r'.*PRESENT=(\d)', re.S) -capacity_p = re.compile(r'.*CAPACITY=(\d+)', re.S) -energynow_p = re.compile(r'.*ENERGY_NOW=(\d+)', re.S) -powernow_p = re.compile(r'.*POWER_NOW=(\d+)', re.S) - - -class Py3status: - """ - Battery module to show battery information. - - battery status: Full, Discharging, Charging, Unknown - """ - - def mybattery(self, i3status_output_json, i3status_config): - """ - Display battery information. - """ - response = { - 'full_text': '', - 'name': 'mybattery', - 'instance': 'first', - } - # open battery uevent file - with open(BAT_UEVENT, 'r') as bat_f: - bat_info = bat_f.read() - status_m = status_p.match(bat_info) - capacity_m = capacity_p.match(bat_info) - energynow_m = energynow_p.match(bat_info) - powernow_m = powernow_p.match(bat_info) - self.status = status_m.group(1) - self.capacity = int(capacity_m.group(1)) - energynow = int(energynow_m.group(1)) - powernow = int(powernow_m.group(1)) - # - bat_text = '{0}%'.format(self.capacity) - if self.status == 'Full': - prompt = '' # Icons: uF213 (battery-full) - color = i3status_config['color_good'] - elif self.status == 'Charging': - prompt = '' # Icons: uF211 (battery-charing) - color = i3status_config['color_degraded'] - elif self.status == 'Discharging': - if self.capacity > 80: - prompt = '' # Icons: uF213 (battery-full) - color = i3status_config['color_good'] - elif self.capacity > 60: - prompt = '' # Icons: uF214 (battery-high) - color = i3status_config['color_degraded'] - elif self.capacity > 30: - prompt = '' # Icons: uF215 (battery-low) - color = i3status_config['color_degraded'] - else: - prompt = '' # Icons: uF212 (battery-empty) - color = i3status_config['color_bad'] - # calc remaining time - remaining_h = energynow // powernow - remaining_m = int((energynow % powernow) / powernow * 60) - if remaining_h: - remaining = '{0}h{1:02d}m'.format(remaining_h, remaining_m) - else: - remaining = '{0:02d}m'.format(remaining_m) - bat_text = '{0} {1}'.format(bat_text, remaining) - else: - # unknown battery status - prompt = '' # Icons: uF215 (battery-low) - prompt = prompt + ' ' # Icons: uF243 (question-sign) - color = i3status_config['color_bad'] - # - response['full_text'] = '{0} {1}'.format(prompt, bat_text) - response['color'] = color - # cache status for 5 seconds - response['cached_until'] = time.time() + 5 - return (POSITION, response) - diff --git a/.i3/py3status/80-datetime.py b/.i3/py3status/80-datetime.py deleted file mode 100644 index 5d578a0..0000000 --- a/.i3/py3status/80-datetime.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Weitian LI -# 2014/05/15 - -""" -datetime module for py3status -""" - -## Get output of shell command: -## python 3.x: -## >>> subprocess.getoutput(cmd) -## >>> subprocess.getstatusoutput(cmd) -## python 2.7.x: -## >>> subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) - -import re -import subprocess -import time - - -# regext to match date and time from output of 'date' -datetime_p = re.compile(r'(^\d+/\d+)\s*(\d+:\d+)') - - -class Py3status: - """ - Datetime module to show current date and time. - """ - - def mydate(self, i3status_output_json, i3status_config): - """ - Display current date. - """ - POSITION = 0 - response = { - 'full_text': '', - 'name': 'mydate', - 'instance': 'first', - } - prompt = '' # Icons: uF073 (calendar) - # update datetime - self._get_datetime() - response['full_text'] = '{0} {1}'.format(prompt, self.date) - # cache status for 5 seconds - response['cached_until'] = time.time() + 5 - return (POSITION, response) - - def mytime(self, i3status_output_json, i3status_config): - """ - Display current time. - """ - POSITION = 1 - response = { - 'full_text': '', - 'name': 'mytime', - 'instance': 'first', - } - prompt = '' # Icons: uF017 (clock) - # update datetime - self._get_datetime() - response['full_text'] = '{0} {1}'.format(prompt, self.time) - # cache status for 5 seconds - response['cached_until'] = time.time() + 5 - return (POSITION, response) - - def _get_datetime(self): - """ - Get current date and time - """ - cmd = 'date "+%m/%d %H:%M"' - datetime = subprocess.getoutput(cmd) - dt_m = datetime_p.match(datetime) - self.date, self.time = dt_m.group(1, 2) - diff --git a/.i3/py3status/backup/dpms.py b/.i3/py3status/backup/dpms.py deleted file mode 100644 index 783c53c..0000000 --- a/.i3/py3status/backup/dpms.py +++ /dev/null @@ -1,44 +0,0 @@ -from os import system - - -class Py3status: - """ - This module allows activation and deactivation - of DPMS (Display Power Management Signaling) - by clicking on 'DPMS' in the status bar. - - Written and contributed by @tasse: - Andre Doser - """ - def __init__(self): - """ - Detect current state on start. - """ - self.run = system('xset -q | grep -iq "DPMS is enabled"') == 0 - - def dpms(self, i3status_output_json, i3status_config): - """ - Display a colorful state of DPMS. - """ - result = { - 'full_text': 'DPMS', - 'name': 'dpms' - } - if self.run: - result['color'] = i3status_config['color_good'] - else: - result['color'] = i3status_config['color_bad'] - return (0, result) - - def on_click(self, json, i3status_config, event): - """ - Enable/Disable DPMS on left click. - """ - if event['button'] == 1: - if self.run: - self.run = False - system("xset -dpms") - else: - self.run = True - system("xset +dpms") - system("killall -USR1 py3status") diff --git a/.i3/py3status/backup/empty_class.py b/.i3/py3status/backup/empty_class.py deleted file mode 100644 index 077269c..0000000 --- a/.i3/py3status/backup/empty_class.py +++ /dev/null @@ -1,41 +0,0 @@ -class Py3status: - """ - Empty and basic py3status class. - - NOTE: py3status will NOT execute: - - methods starting with '_' - - methods decorated by @property and @staticmethod - - NOTE: reserved method names: - - 'kill' method for py3status exit notification - - 'on_click' method for click events from i3bar - """ - def kill(self, i3status_output_json, i3status_config): - """ - This method will be called upon py3status exit. - """ - pass - - def on_click(self, i3status_output_json, i3status_config, event): - """ - This method will be called when a click event occurs on this module's - output on the i3bar. - - Example 'event' json object: - {'y': 13, 'x': 1737, 'button': 1, 'name': 'empty', 'instance': 'first'} - """ - pass - - def empty(self, i3status_output_json, i3status_config): - """ - This method will return an empty text message - so it will NOT be displayed on your i3bar. - - If you want something displayed you should write something - in the 'full_text' key of your response. - - See the i3bar protocol spec for more information: - http://i3wm.org/docs/i3bar-protocol.html - """ - response = {'full_text': '', 'name': 'empty', 'instance': 'first'} - return (0, response) diff --git a/.i3/py3status/backup/glpi.py b/.i3/py3status/backup/glpi.py deleted file mode 100644 index 929749d..0000000 --- a/.i3/py3status/backup/glpi.py +++ /dev/null @@ -1,52 +0,0 @@ -# You need MySQL-python from http://pypi.python.org/pypi/MySQL-python -import MySQLdb - - -class Py3status: - """ - This example class demonstrates how to display the current total number of - open tickets from GLPI in your i3bar. - - It features thresholds to colorize the output and forces a low timeout to - limit the impact of a server connectivity problem on your i3bar freshness. - - Note that we don't have to implement a cache layer as it is handled by - py3status automagically. - """ - def count_glpi_open_tickets(self, json, i3status_config): - response = {'full_text': '', 'name': 'glpi_tickets'} - - # user-defined variables - CRIT_THRESHOLD = 20 - WARN_THRESHOLD = 15 - MYSQL_DB = '' - MYSQL_HOST = '' - MYSQL_PASSWD = '' - MYSQL_USER = '' - POSITION = 0 - - mydb = MySQLdb.connect( - host=MYSQL_HOST, - user=MYSQL_USER, - passwd=MYSQL_PASSWD, - db=MYSQL_DB, - connect_timeout=5, - ) - mycr = mydb.cursor() - mycr.execute('''select count(*) - from glpi_tickets - where closedate is NULL and solvedate is NULL;''') - row = mycr.fetchone() - if row: - open_tickets = int(row[0]) - if i3status_config['colors']: - if open_tickets > CRIT_THRESHOLD: - response.update({'color': i3status_config['color_bad']}) - elif open_tickets > WARN_THRESHOLD: - response.update( - {'color': i3status_config['color_degraded']} - ) - response['full_text'] = '%s tickets' % open_tickets - mydb.close() - - return (POSITION, response) diff --git a/.i3/py3status/backup/i3bar_click_events.py b/.i3/py3status/backup/i3bar_click_events.py deleted file mode 100644 index 792965c..0000000 --- a/.i3/py3status/backup/i3bar_click_events.py +++ /dev/null @@ -1,127 +0,0 @@ -from subprocess import Popen -from time import time - - -class Py3status: - """ - This module allows you to take actions based on click events made on - the i3status modules. For example, thanks to this module you could - launch the wicd GUI when clicking on the ethernet or wireless module - of your i3status output ! - - IMPORTANT: - This module file name is reserved and should NOT be changed if you - want py3status to handle your i3status modules click events ! - - The behavior described above will only work if this file is named - 'i3bar_click_events.py' ! - """ - def __init__(self): - """ - This is where you setup your actions based on your i3status config. - - Configuration: - -------------- - self.actions = { - "": { -