├── .gitignore ├── .xinitrc ├── README.md ├── config_i3menu ├── config_work_laptop ├── conky ├── JSON.lua ├── brightnesslevel.sh ├── conky-i3bar ├── conky.conf ├── conky.lua ├── convert.lua ├── info.py ├── volumelevel.py ├── volumelevel.sh └── weather.sh ├── i3blocks.conf ├── i3exit └── i3status.conf /.gitignore: -------------------------------------------------------------------------------- 1 | config 2 | -------------------------------------------------------------------------------- /.xinitrc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #if [ -d /etc/X11/xinit/xinitrc.d ]; then 4 | # for f in /etc/X11/xinit/xinitrc.d/*; do 5 | # [ -x "$f" ] && . "$f" 6 | # done 7 | # unset f 8 | #fi 9 | # 10 | [[ -f ~/.Xresources ]] && xrdb -merge "${HOME}/.Xresources" 11 | 12 | # this let you toggle between different keyboard layouts 13 | setxkbmap -option grp:alt_shift_toggle us,it 14 | sh ./.fehbg & 15 | 16 | 17 | # Start a D-Bus session 18 | source /etc/X11/xinit/xinitrc.d/30-dbus 19 | # Start GNOME Keyring 20 | eval $(/usr/bin/gnome-keyring-daemon --start --components=gpg,pkcs11,secrets,ssh) 21 | export SSH_AUTH_SOCK 22 | export GPG_AGENT_INFO 23 | export GNOME_KEYRING_CONTROL 24 | export GNOME_KEYRING_PID 25 | export OOO_FORCE_DESKTOP=gnome 26 | export LANG="en_US.UTF-8" 27 | export LC_ALL="en_US.UTF-8" 28 | export LANGUAGE="en_US.UTF-8" 29 | export LC_CTYPE="en_US.UTF-8" 30 | export TERMINAL='gnome-terminal' 31 | 32 | # exec xrandr --output DP1 --primary 33 | # Launch i3 window manager 34 | eval $(dbus-launch --sh-syntax) 35 | export XDG_CURRENT_DESKTOP=GNOME 36 | exec i3 37 | 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # i3 Configuration 2 | 3 | ## Requirements 4 | ### general 5 | * i3 - window manager 6 | * i3status - status bar 7 | * feh - setting bg, also nice image viewer 8 | * pulseaudio - audio managment 9 | * dmenu - Super-P launcher 10 | * pavucontrol - pulseaudio mixer 11 | * alsamixer 12 | * scrot - screenshots 13 | * acpi - for volume infos 14 | * conky - better sys informations 15 | * jq - for parse weather info 16 | * bc - for calculating current brightness level 17 | ### from xorg 18 | * setxkbmap - setting keyboard layout 19 | 20 | 21 | ##Installation 22 | It's as simple as that: 23 | 24 | ```bash 25 | cd ~ 26 | git clone https://github.com/giacomos/i3wm-config.git .i3 27 | ln -s .i3/i3status.conf ~/.i3status.conf 28 | ln -s .i3/xinitrc ~/.xinitrc 29 | ln -s .i3/xinitrc ~/.xsession 30 | cd .i3 31 | ln -s config_work_laptop config 32 | ``` 33 | 34 | Create a new file /usr/share/xsessions/custom.desktop with: 35 | ``` 36 | [Desktop Entry] 37 | Name=Xsession 38 | Exec=/etc/X11/Xsession 39 | ``` 40 | You should now have a new session option during login, Xsession will load the user's ~/.xsession file 41 | -------------------------------------------------------------------------------- /config_i3menu: -------------------------------------------------------------------------------- 1 | # vim:filetype=i3 2 | # 3 | # Please see http://i3wm.org/docs/userguide.html for a complete reference! 4 | 5 | smart_gaps on 6 | gaps inner 10 7 | # gaps outer 10 8 | smart_borders on 9 | 10 | set $mod Mod4 11 | 12 | set $OUTPUT_E HDMI2 13 | set $OUTPUT_I eDP1 14 | 15 | set $i3_path ~/.i3 16 | set $pictures_folder ~/Pictures 17 | 18 | # Fancy names for workspaces 19 | set $w1 1: WWW 20 | set $w2 2: TERM 21 | # set $w3 3: MAIL 22 | set $w3 3: HIPCHAT 23 | set $w4 4: CHAT 24 | set $w5 5: FILE 25 | set $w6 6 26 | set $w7 7 27 | set $w8 8 28 | set $w9 9 29 | set $w10 10 30 | 31 | # http://i3wm.org/docs/userguide.html#_layout_mode_for_new_containers 32 | workspace_layout tabbed 33 | 34 | ## my custom binds 35 | bindsym $mod+Ctrl+l exec xset dpms force off && i3lock -c 000000 36 | #bindsym $mod+Ctrl+l exec --no-startup-id $i3_path/i3exit lock, mode "default" 37 | #bindsym $mod+n exec nautilus --no-desktop & 38 | bindsym $mod+n exec thunar 39 | bindsym $mod+Shift+B exec i3-input -F 'exec $i3_path/conky/brightnesslevel.sh set %s' -P 'Set brightness to: ' 40 | bindsym Mod1+Shift+K exec i3-input -F 'exec setxkbmap %s' -P 'Set keyboard layout to: ' 41 | 42 | ## Assign section 43 | assign [class="^Firefox$"] → $w1 44 | assign [title="^DownThemAll$"] → $w1 45 | assign [title="^Print$"] → $w1 46 | assign [class="terminal"] → $w2 47 | assign [class="^Roxterm$"] → $w2 48 | # assign [class="^HipChat$"] → $w3 49 | assign [class="^Evolution$"] → $w3 50 | assign [class="Buddy List"] → $w4 51 | assign [class="Pidgin"] → $w4 52 | assign [class="^Nautilus$"] → $w5 53 | assign [class="^Thunar$"] → $w5 54 | assign [class="^Surf$"] → $w1 55 | assign [instance="^Weechat"] → $w3 56 | assign [class="^Google-chrome$"] → $w1 57 | 58 | #for_window [class="Guake"] floating enable 59 | for_window [window_role="pop-up"] floating enable 60 | for_window [window_role="prefwindow"] floating enable 61 | for_window [class="^Skype$"] floating enable 62 | for_window [class="notify"] floating enable border 1pixel 63 | for_window [class="update-manager"] floating enable border 1pixel 64 | # for_window [class="gnome-calculator"] floating enable border 1pixel resize 640 480 65 | for_window [title="Kupfer"] floating enable border 1pixel 66 | #for_window [class="terminal"] border 1pixel 67 | for_window [title="Pidgin"] move left; resize shrink right 31px or 31 ppt 68 | for_window [class="gnome-panel"] move to output $OUTPUT_E 69 | for_window [class="vlc"] floating enable 70 | for_window [class="^Roxterm$"] border 1pixel 71 | 72 | # summon most used apps 73 | bindsym $mod+F1 [class="Firefox"] move workspace current 74 | bindsym $mod+F2 [class="terminal"] move workspace current 75 | 76 | # Get me to the next open VIM instance 77 | #bindsym Ctrl+grave [class="terminal"] focus 78 | 79 | # Show the first scratchpad window 80 | bindsym Ctrl+grave scratchpad show 81 | 82 | # The middle button over a titlebar kills the window 83 | bindsym --release button2 kill 84 | 85 | # Screen Shots 86 | bindsym --release $mod+x exec --no-startup-id import /tmp/latest-screenshot.png 87 | bindsym Print exec scrot -e 'mv $f $pictures_folder/Scrot/$f' 88 | bindsym Mod1+Print exec scrot -u -e 'mv $f $pictures_folder/Scrot/$f' 89 | bindsym $mod+Print exec scrot 90 | bindsym $mod+Mod1+Print exec scrot -u -e 'mv $f $pictures_folder/Scrot/$f && gimp $pictures_folder/Scrot/$f' 91 | 92 | # start a terminal 93 | bindsym $mod+Return exec /usr/bin/roxterm 94 | bindsym $mod+Shift+Return exec gnome-terminal 95 | 96 | # Font for window titles. Will also be used by the bar unless a different font 97 | # is used in the bar {} block below. ISO 10646 = Unicode 98 | #font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 99 | # The font above is very space-efficient, that is, it looks good, sharp and 100 | # clear in small sizes. However, if you need a lot of unicode glyphs or 101 | # right-to-left text rendering, you should instead use pango for rendering and 102 | # chose a FreeType font, such as: 103 | #font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 104 | #font pango:Ubuntu 9 105 | #font pango:DejaVu Sans Mono 10 106 | #font pango:DejaVu Sans Mono, Terminus Semi-Condensed 8 107 | font pango:Orbitron 9 108 | 109 | # next/previous workspace 110 | bindsym $mod+Tab workspace next 111 | bindsym $mod+Shift+Tab workspace prev 112 | #bindsym $mod+Tab workspace back_and_forth 113 | bindsym $mod+Mod1+Right workspace next 114 | bindsym $mod+Mod1+Left workspace prev 115 | 116 | #bindsym $mod+s layout stacking 117 | bindsym $mod+t layout tabbed 118 | bindsym $mod+e layout toggle split 119 | 120 | # Use Mouse+$mod to drag floating windows to their wanted position 121 | floating_modifier $mod 122 | 123 | # kill focused window 124 | bindsym $mod+Shift+q kill 125 | #bindsym $mod+Ctrl+l exec i3lock -n -ti $pictures_folder/wallpaper.png 126 | bindsym XF86AudioRaiseVolume exec "amixer -D pulse sset Master '5%+'" 127 | bindsym XF86AudioLowerVolume exec "amixer -D pulse sset Master '5%-'" 128 | bindsym XF86AudioMute exec "amixer -D pulse set Master toggle" 129 | 130 | #bindsym XF86AudioPlay exec "~/.bin/player toggle" 131 | #bindsym XF86AudioStop exec "~/.bin/player stop" 132 | #bindsym XF86AudioNext exec "~/.bin/player next" 133 | #bindsym XF86AudioPrev exec "~/.bin/player previous" 134 | 135 | bindsym $mod+space exec --no-startup-id i3-dmenu-desktop --dmenu='rofi -i -dmenu -p "run:"' 136 | bindsym $mod+g exec --no-startup-id rofi -fuzzy -show window 137 | 138 | bindsym $mod+r exec --no-startup-id i3menu root 139 | bindsym $mod+Shift+G exec --no-startup-id i3menu goto_actions 140 | bindsym $mod+b exec --no-startup-id i3menu bar_actions 141 | bindsym $mod+i exec --no-startup-id i3menu global_actions 142 | bindsym $mod+s exec --no-startup-id i3menu scratchpad_actions 143 | bindsym $mod+l exec --no-startup-id i3menu layout 144 | bindsym $mod+w exec --no-startup-id i3menu window_actions 145 | bindsym $mod+Shift+W exec --no-startup-id i3menu target_window_actions 146 | bindsym $mod+k exec --no-startup-id i3menu workspace_actions 147 | bindsym $mod+Shift+K exec --no-startup-id i3menu target_workspace_actions 148 | 149 | bindsym $mod+m exec --no-startup-id ~/.dotfiles/bin/monitors_layout 150 | bindsym $mod+Shift+E exec --no-startup-id ~/.dotfiles/bin/rofi_power_management 151 | 152 | # change focus 153 | bindsym $mod+Left focus left 154 | bindsym $mod+Down focus down 155 | bindsym $mod+Up focus up 156 | bindsym $mod+Right focus right 157 | 158 | # move focused window 159 | bindsym $mod+Shift+Left move left 160 | bindsym $mod+Shift+Down move down 161 | bindsym $mod+Shift+Up move up 162 | bindsym $mod+Shift+Right move right 163 | 164 | # split in horizontal orientation 165 | bindsym $mod+h split h 166 | 167 | # split in vertical orientation 168 | bindsym $mod+v split v 169 | 170 | # change focus between tiling / floating windows 171 | #bindsym $mod+space focus mode_toggle 172 | bindsym $mod+Shift+f floating toggle 173 | 174 | # focus the parent container 175 | bindsym $mod+a focus parent 176 | 177 | # focus the child container 178 | #bindsym $mod+d focus child 179 | 180 | # switch to workspace 181 | bindsym $mod+1 workspace $w1 182 | bindsym $mod+2 workspace $w2 183 | bindsym $mod+3 workspace $w3 184 | bindsym $mod+4 workspace $w4 185 | bindsym $mod+5 workspace $w5 186 | bindsym $mod+6 workspace $w6 187 | bindsym $mod+7 workspace $w7 188 | bindsym $mod+8 workspace $w8 189 | bindsym $mod+9 workspace $w9 190 | bindsym $mod+0 workspace $w10 191 | 192 | # move focused container to workspace 193 | bindsym $mod+Shift+1 move container to workspace $w1 194 | bindsym $mod+Shift+2 move container to workspace $w2 195 | bindsym $mod+Shift+3 move container to workspace $w3 196 | bindsym $mod+Shift+4 move container to workspace $w4 197 | bindsym $mod+Shift+5 move container to workspace $w5 198 | bindsym $mod+Shift+6 move container to workspace $w6 199 | bindsym $mod+Shift+7 move container to workspace $w7 200 | bindsym $mod+Shift+8 move container to workspace $w8 201 | bindsym $mod+Shift+9 move container to workspace $w9 202 | bindsym $mod+Shift+0 move container to workspace $w10 203 | 204 | # reload the configuration file 205 | bindsym $mod+Shift+c reload 206 | # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) 207 | bindsym $mod+Shift+r restart 208 | 209 | # resize window (you can also use the mouse for that) 210 | mode "resize" { 211 | # These bindings trigger as soon as you enter the resize mode 212 | bindsym $mod+Mod1+R mode "i3menu" 213 | # Pressing left will shrink the window’s width. 214 | # Pressing right will grow the window’s width. 215 | # Pressing up will shrink the window’s height. 216 | # Pressing down will grow the window’s height. 217 | bindsym j resize shrink width 10 px or 10 ppt 218 | bindsym k resize grow height 10 px or 10 ppt 219 | bindsym l resize shrink height 10 px or 10 ppt 220 | bindsym ograve resize grow width 10 px or 10 ppt 221 | 222 | # same bindings, but for the arrow keys 223 | bindsym Left resize shrink width 10 px or 10 ppt 224 | bindsym Down resize grow height 10 px or 10 ppt 225 | bindsym Up resize shrink height 10 px or 10 ppt 226 | bindsym Right resize grow width 10 px or 10 ppt 227 | 228 | # back to normal: Enter or Escape 229 | bindsym Return mode "default" 230 | bindsym Escape mode "default" 231 | } 232 | bindsym $mod+Mod1+R mode "resize" 233 | 234 | # Start i3bar to display a workspace bar (plus the system information i3status 235 | # finds out, if available) 236 | bar { 237 | id bar-0 238 | tray_output none 239 | position top 240 | status_command $i3_path/conky/conky-i3bar 241 | # i3bar_command $i3_path/lemonbar/i3_lemonbar.sh 242 | 243 | colors { 244 | background #24364F 245 | statusline #CCCCCC 246 | 247 | focused_workspace #ffffff #285577 248 | active_workspace #cccccc #333333 249 | inactive_workspace #999999 #222222 250 | urgent_workspace #ffffff #900000 251 | } 252 | } 253 | # bar { 254 | # id bar-1 255 | # workspace_buttons off 256 | # tray_output off 257 | # position top 258 | # status_command $i3_path/conky/conky-i3bar-networks 259 | # colors { 260 | # background #24364F 261 | # statusline #CCCCCC 262 | # 263 | # focused_workspace #ffffff #285577 264 | # active_workspace #cccccc #333333 265 | # inactive_workspace #999999 #222222 266 | # urgent_workspace #ffffff #900000 267 | # } 268 | # } 269 | 270 | # Original windows decoration colors 271 | # class border backgr. text indicator 272 | client.focused #4c7899 #285577 #ffffff #2e9ef4 273 | #client.focused #4c7899 #285577 #ffffff #2e9ef4 274 | #client.focused_inactive #333333 #5f676a #ffffff #484e50 275 | #client.unfocused #333333 #222222 #888888 #292d2e 276 | #client.urgent #2f343a #900000 #ffffff #900000 277 | client.unfocused #4c7899 #24364F #aaaaaa #2e9ef4 278 | client.focused #c10101 #880404 #ffffff #00AA00 279 | 280 | # hide vertical borders adjacent to the screen edges 281 | hide_edge_borders both 282 | 283 | # This prevent the focus to follow mouse movements 284 | #focus_follows_mouse no 285 | 286 | ## Autostart section 287 | # exec --no-startup-id gnome-settings-daemon 288 | exec --no-startup-id nm-applet 289 | # exec --no-startup-id gnome-sound-applet 290 | exec --no-startup-id roxterm 291 | exec --no-startup-id compton -b 292 | exec --no-startup-id xbindkeys 293 | # exec --no-startup-id firefox 294 | 295 | # The lightweight GTK+ clipboard manager. 296 | exec --no-startup-id feh --bg-scale /home/jack/Pictures/wallpaper.jpg 297 | 298 | # exec --no-startup-id dropbox start 299 | exec --no-startup-id dropbox stop && DBUS_SESSION_BUS_ADDRESS="" dropbox start 300 | exec --no-startup-id pulseaudio --start 301 | exec --no-startup-id xrandr --output $OUTPUT_E --auto --right-of $OUTPUT_I 302 | 303 | # set $USER_AGENT AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 304 | # # rancher 305 | # exec --no-startup-id "sleep 30;surf http://localhost:8888" 306 | # # gmail 307 | # exec --no-startup-id "sleep 45;surf -u '$USER_AGENT' https://mail.google.com" 308 | 309 | 310 | ## Workspaces 311 | #workspace_auto_back_and_forth yes 312 | workspace "$w1" output $OUTPUT_E 313 | workspace "$w2" output $OUTPUT_E 314 | workspace "$w3" output $OUTPUT_E 315 | workspace "$w4" output $OUTPUT_I 316 | -------------------------------------------------------------------------------- /config_work_laptop: -------------------------------------------------------------------------------- 1 | # vim:filetype=i3 2 | # 3 | # Please see http://i3wm.org/docs/userguide.html for a complete reference! 4 | 5 | set $mod Mod4 6 | 7 | set $i3_path /home/jack/.i3 8 | set $pictures_folder /home/jack/Pictures 9 | 10 | # Fancy names for workspaces 11 | set $w1 1: www 12 | set $w2 2: terminal 13 | set $w3 3: chat&mail 14 | set $w4 4 15 | set $w5 5 16 | set $w6 6 17 | set $w7 7 18 | set $w8 8 19 | set $w9 9 20 | set $w10 10 21 | 22 | ## my custom binds 23 | bindsym $mod+Ctrl+l exec i3lock -c 000000 -i $pictures_folder/wallpaper.png -t # && sudo pm-suspend 24 | #bindsym $mod+Ctrl+l exec --no-startup-id $i3_path/i3exit lock, mode "default" 25 | bindsym $mod+b exec nautilus --no-desktop & 26 | 27 | ## Assign section 28 | assign [class="^Firefox$"] → $w1 29 | assign [title="^DownThemAll$"] → $w1 30 | assign [title="^Print$"] → $w1 31 | assign [class="Pidgin"] → $w3 32 | assign [class="Buddy List"] → $w3 33 | assign [class="^Thunderbird$"] → $w3 34 | 35 | #for_window [class="Guake"] floating enable 36 | for_window [window_role="pop-up"] floating enable 37 | for_window [title="Calculator"] floating enable 38 | for_window [title="Calculator"] border 1pixel 39 | for_window [class="terminal"] border 1pixel 40 | #for_window [class="^Thunderbird$"] move workspace $w4 41 | for_window [title="Pidgin"] move left; resize shrink right 31px or 31 ppt 42 | 43 | # summon most used apps 44 | bindsym $mod+F1 [class="Firefox"] move workspace current 45 | bindsym $mod+F2 [class="terminal"] move workspace current 46 | bindsym $mod+F3 [class="Thunderbird"] move workspace current 47 | 48 | # Get me to the next open VIM instance 49 | #bindsym Ctrl+grave [class="terminal"] focus 50 | 51 | # Make the currently focused window a scratchpad 52 | bindsym $mod+Shift+minus move scratchpad 53 | 54 | # Show the first scratchpad window 55 | bindsym Ctrl+grave scratchpad show 56 | 57 | # Screen Shots 58 | bindsym Print exec scrot -e 'mv $f $pictures_folder/Scrot/$f' 59 | bindsym Mod1+Print exec scrot -u -e 'mv $f $pictures_folder/Scrot/$f' 60 | bindsym $mod+Print exec scrot -e 'mv $f $pictures_folder/Scrot/$f && gimp $pictures_folder/Scrot/$f' 61 | bindsym $mod+Mod1+Print exec scrot -u -e 'mv $f $pictures_folder/Scrot/$f && gimp $pictures_folder/Scrot/$f' 62 | 63 | # move workspace to outputs 64 | bindsym $mod+Mod1+Left move workspace to output left 65 | bindsym $mod+Mod1+Down move workspace to output down 66 | bindsym $mod+Mod1+Up move workspace to output up 67 | bindsym $mod+Mod1+Right move workspace to output right 68 | 69 | # start a terminal 70 | bindsym $mod+Return exec i3-sensible-terminal 71 | 72 | # rename workspace 73 | bindsym $mod+Shift+y exec i3-input -F 'rename workspace to "%s"' -P 'New name: ' 74 | 75 | # Font for window titles. Will also be used by the bar unless a different font 76 | # is used in the bar {} block below. ISO 10646 = Unicode 77 | #font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 78 | # The font above is very space-efficient, that is, it looks good, sharp and 79 | # clear in small sizes. However, if you need a lot of unicode glyphs or 80 | # right-to-left text rendering, you should instead use pango for rendering and 81 | # chose a FreeType font, such as: 82 | font pango:Ubuntu 10 83 | 84 | # next/previous workspace 85 | bindsym Mod1+Tab workspace next 86 | bindsym Mod1+Shift+Tab workspace prev 87 | bindsym $mod+Tab workspace back_and_forth 88 | 89 | bindsym $mod+s layout stacking 90 | bindsym $mod+w layout tabbed 91 | bindsym $mod+e layout toggle split 92 | 93 | # Use Mouse+$mod to drag floating windows to their wanted position 94 | floating_modifier $mod 95 | 96 | # kill focused window 97 | bindsym $mod+Shift+q kill 98 | #bindsym $mod+Ctrl+l exec i3lock -n -ti $pictures_folder/wallpaper.png 99 | bindsym XF86AudioRaiseVolume exec "amixer -D pulse sset Master '5%+'" 100 | bindsym XF86AudioLowerVolume exec "amixer -D pulse sset Master '5%-'" 101 | bindsym XF86AudioMute exec "amixer -D pulse set Master toggle" 102 | 103 | #bindsym XF86AudioPlay exec "~/.bin/player toggle" 104 | #bindsym XF86AudioStop exec "~/.bin/player stop" 105 | #bindsym XF86AudioNext exec "~/.bin/player next" 106 | #bindsym XF86AudioPrev exec "~/.bin/player previous" 107 | 108 | # start dmenu (a program launcher) 109 | #bindsym $mod+d exec dmenu_run 110 | # There also is the (new) i3-dmenu-desktop which only displays applications 111 | # shipping a .desktop file. It is a wrapper around dmenu, so you need that 112 | # installebindsym $mod+d exec --no-startup-id i3-dmenu-desktop --dmenu="/usr/bin/dmenu -l 5 -fn 'xft:Terminus:pixelsize=8' -nb '#191919' -nf '#9ac0cd' -sb '#191919' -sf '#bf3f34' -p 'search app >> '" 113 | bindsym $mod+d exec --no-startup-id i3-dmenu-desktop --dmenu="/usr/bin/dmenu -b -fn 'xft:Terminus:pixelsize=8' -nb '#191919' -nf '#9ac0cd' -sb '#191919' -sf '#bf3f34' -p 'search app >> '" 114 | 115 | # change focus 116 | bindsym $mod+j focus left 117 | bindsym $mod+k focus down 118 | bindsym $mod+l focus up 119 | bindsym $mod+ograve focus right 120 | 121 | # alternatively, you can use the cursor keys: 122 | bindsym $mod+Left focus left 123 | bindsym $mod+Down focus down 124 | bindsym $mod+Up focus up 125 | bindsym $mod+Right focus right 126 | 127 | # move focused window 128 | bindsym $mod+Shift+j move left 129 | bindsym $mod+Shift+k move down 130 | bindsym $mod+Shift+l move up 131 | bindsym $mod+Shift+ograve move right 132 | 133 | # alternatively, you can use the cursor keys: 134 | bindsym $mod+Shift+Left move left 135 | bindsym $mod+Shift+Down move down 136 | bindsym $mod+Shift+Up move up 137 | bindsym $mod+Shift+Right move right 138 | 139 | # split in horizontal orientation 140 | bindsym $mod+h split h 141 | 142 | # split in vertical orientation 143 | bindsym $mod+v split v 144 | 145 | # enter fullscreen mode for the focused container 146 | bindsym $mod+f fullscreen 147 | 148 | # toggle tiling / floating 149 | bindsym $mod+Shift+space floating toggle 150 | 151 | # change focus between tiling / floating windows 152 | bindsym $mod+space focus mode_toggle 153 | 154 | # focus the parent container 155 | bindsym $mod+a focus parent 156 | 157 | # focus the child container 158 | #bindsym $mod+d focus child 159 | 160 | # switch to workspace 161 | bindsym $mod+1 workspace $w1 162 | bindsym $mod+2 workspace $w2 163 | bindsym $mod+3 workspace $w3 164 | bindsym $mod+4 workspace $w4 165 | bindsym $mod+5 workspace $w5 166 | bindsym $mod+6 workspace $w6 167 | bindsym $mod+7 workspace $w7 168 | bindsym $mod+8 workspace $w8 169 | bindsym $mod+9 workspace $w9 170 | bindsym $mod+0 workspace $w10 171 | 172 | # move focused container to workspace 173 | bindsym $mod+Shift+1 move container to workspace $w1 174 | bindsym $mod+Shift+2 move container to workspace $w2 175 | bindsym $mod+Shift+3 move container to workspace $w3 176 | bindsym $mod+Shift+4 move container to workspace $w4 177 | bindsym $mod+Shift+5 move container to workspace $w5 178 | bindsym $mod+Shift+6 move container to workspace $w6 179 | bindsym $mod+Shift+7 move container to workspace $w7 180 | bindsym $mod+Shift+8 move container to workspace $w8 181 | bindsym $mod+Shift+9 move container to workspace $w9 182 | bindsym $mod+Shift+0 move container to workspace $w10 183 | 184 | # reload the configuration file 185 | bindsym $mod+Shift+c reload 186 | # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) 187 | bindsym $mod+Shift+r restart 188 | 189 | # exit i3 (logs you out of your X session) 190 | #bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" 191 | # Create Log out, Reboot, Poweroff bindings 192 | 193 | set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown 194 | mode "$mode_system" { 195 | bindsym l exec --no-startup-id $i3_path/i3exit lock, mode "default" 196 | bindsym e exec --no-startup-id $i3_path/i3exit logout, mode "default" 197 | bindsym s exec --no-startup-id $i3_path/i3exit suspend, mode "default" 198 | bindsym h exec --no-startup-id $i3_path/i3exit hibernate, mode "default" 199 | bindsym r exec --no-startup-id $i3_path/i3exit reboot, mode "default" 200 | bindsym Shift+s exec --no-startup-id $i3_path/i3exit shutdown, mode "default" 201 | # back to normal: Enter or Escape 202 | bindsym Return mode "default" 203 | bindsym Escape mode "default" 204 | } 205 | bindsym $mod+Shift+e mode "$mode_system" 206 | 207 | # resize window (you can also use the mouse for that) 208 | mode "resize" { 209 | # These bindings trigger as soon as you enter the resize mode 210 | 211 | # Pressing left will shrink the window’s width. 212 | # Pressing right will grow the window’s width. 213 | # Pressing up will shrink the window’s height. 214 | # Pressing down will grow the window’s height. 215 | bindsym j resize shrink width 10 px or 10 ppt 216 | bindsym k resize grow height 10 px or 10 ppt 217 | bindsym l resize shrink height 10 px or 10 ppt 218 | bindsym ograve resize grow width 10 px or 10 ppt 219 | 220 | # same bindings, but for the arrow keys 221 | bindsym Left resize shrink width 10 px or 10 ppt 222 | bindsym Down resize grow height 10 px or 10 ppt 223 | bindsym Up resize shrink height 10 px or 10 ppt 224 | bindsym Right resize grow width 10 px or 10 ppt 225 | 226 | # back to normal: Enter or Escape 227 | bindsym Return mode "default" 228 | bindsym Escape mode "default" 229 | } 230 | bindsym $mod+r mode "resize" 231 | 232 | set $mode_move Move workspace: (L)eft, (Right) 233 | mode "$mode_move" { 234 | bindsym l move workspace to output left 235 | bindsym r move workspace to output right 236 | # back to normal: Enter or Escape 237 | bindsym Return mode "default" 238 | bindsym Escape mode "default" 239 | } 240 | bindsym $mod+m mode "$mode_move" 241 | 242 | set $mode_external_pos External screen is on (l)eft or (r)ight of the internal one? 243 | mode "$mode_external_pos" { 244 | bindsym r exec xrandr --output DP1 --mode 1920x1080 --right-of eDP1 245 | bindsym l exec xrandr --output DP1 --mode 1920x1080 --left-of eDP1 246 | # back to normal: Enter or Escape 247 | bindsym Return mode "default" 248 | bindsym Escape mode "default" 249 | } 250 | bindsym $mod+Shift+s mode "$mode_external_pos" 251 | 252 | # Start i3bar to display a workspace bar (plus the system information i3status 253 | # finds out, if available) 254 | bar { 255 | tray_output primary 256 | position top 257 | # status_command i3status --config ~/.i3status.conf 258 | status_command ~/.i3/conky/conky-i3bar 259 | 260 | colors { 261 | background #24364F 262 | statusline #CCCCCC 263 | 264 | focused_workspace #ffffff #285577 265 | active_workspace #cccccc #333333 266 | inactive_workspace #333333 #222222 267 | urgent_workspace #ffffff #900000 268 | } 269 | } 270 | 271 | # Original windows decoration colors 272 | # class border backgr. text indicator 273 | #client.focused #4c7899 #285577 #ffffff #2e9ef4 274 | #client.focused #4c7899 #285577 #ffffff #2e9ef4 275 | #client.focused_inactive #333333 #5f676a #ffffff #484e50 276 | #client.unfocused #333333 #222222 #888888 #292d2e 277 | #client.urgent #2f343a #900000 #ffffff #900000 278 | client.unfocused #4c7899 #24364F #aaaaaa #2e9ef4 279 | client.focused #c10101 #880404 #ffffff #00AA00 280 | 281 | # This prevent the focus to follow mouse movements 282 | #focus_follows_mouse no 283 | 284 | ## Autostart section 285 | exec --no-startup-id firefox 286 | exec --no-startup-id nm-applet 287 | exec --no-startup-id gnome-sound-applet 288 | exec --no-startup-id gnome-terminal 289 | exec --no-startup-id gnome-settings-daemon 290 | exec --no-startup-id thunderbird 291 | exec dropbox start 292 | exec pulseaudio --start 293 | -------------------------------------------------------------------------------- /conky/JSON.lua: -------------------------------------------------------------------------------- 1 | -- -*- coding: utf-8 -*- 2 | -- 3 | -- Simple JSON encoding and decoding in pure Lua. 4 | -- 5 | -- Copyright 2010-2014 Jeffrey Friedl 6 | -- http://regex.info/blog/ 7 | -- 8 | -- Latest version: http://regex.info/blog/lua/json 9 | -- 10 | -- This code is released under a Creative Commons CC-BY "Attribution" License: 11 | -- http://creativecommons.org/licenses/by/3.0/deed.en_US 12 | -- 13 | -- It can be used for any purpose so long as the copyright notice above, 14 | -- the web-page links above, and the 'AUTHOR_NOTE' string below are 15 | -- maintained. Enjoy. 16 | -- 17 | local VERSION = 20141223.14 -- version history at end of file 18 | local AUTHOR_NOTE = "-[ JSON.lua package by Jeffrey Friedl (http://regex.info/blog/lua/json) version 20141223.14 ]-" 19 | 20 | -- 21 | -- The 'AUTHOR_NOTE' variable exists so that information about the source 22 | -- of the package is maintained even in compiled versions. It's also 23 | -- included in OBJDEF below mostly to quiet warnings about unused variables. 24 | -- 25 | local OBJDEF = { 26 | VERSION = VERSION, 27 | AUTHOR_NOTE = AUTHOR_NOTE, 28 | } 29 | 30 | 31 | -- 32 | -- Simple JSON encoding and decoding in pure Lua. 33 | -- http://www.json.org/ 34 | -- 35 | -- 36 | -- JSON = assert(loadfile "JSON.lua")() -- one-time load of the routines 37 | -- 38 | -- local lua_value = JSON:decode(raw_json_text) 39 | -- 40 | -- local raw_json_text = JSON:encode(lua_table_or_value) 41 | -- local pretty_json_text = JSON:encode_pretty(lua_table_or_value) -- "pretty printed" version for human readability 42 | -- 43 | -- 44 | -- 45 | -- DECODING (from a JSON string to a Lua table) 46 | -- 47 | -- 48 | -- JSON = assert(loadfile "JSON.lua")() -- one-time load of the routines 49 | -- 50 | -- local lua_value = JSON:decode(raw_json_text) 51 | -- 52 | -- If the JSON text is for an object or an array, e.g. 53 | -- { "what": "books", "count": 3 } 54 | -- or 55 | -- [ "Larry", "Curly", "Moe" ] 56 | -- 57 | -- the result is a Lua table, e.g. 58 | -- { what = "books", count = 3 } 59 | -- or 60 | -- { "Larry", "Curly", "Moe" } 61 | -- 62 | -- 63 | -- The encode and decode routines accept an optional second argument, 64 | -- "etc", which is not used during encoding or decoding, but upon error 65 | -- is passed along to error handlers. It can be of any type (including nil). 66 | -- 67 | -- 68 | -- 69 | -- ERROR HANDLING 70 | -- 71 | -- With most errors during decoding, this code calls 72 | -- 73 | -- JSON:onDecodeError(message, text, location, etc) 74 | -- 75 | -- with a message about the error, and if known, the JSON text being 76 | -- parsed and the byte count where the problem was discovered. You can 77 | -- replace the default JSON:onDecodeError() with your own function. 78 | -- 79 | -- The default onDecodeError() merely augments the message with data 80 | -- about the text and the location if known (and if a second 'etc' 81 | -- argument had been provided to decode(), its value is tacked onto the 82 | -- message as well), and then calls JSON.assert(), which itself defaults 83 | -- to Lua's built-in assert(), and can also be overridden. 84 | -- 85 | -- For example, in an Adobe Lightroom plugin, you might use something like 86 | -- 87 | -- function JSON:onDecodeError(message, text, location, etc) 88 | -- LrErrors.throwUserError("Internal Error: invalid JSON data") 89 | -- end 90 | -- 91 | -- or even just 92 | -- 93 | -- function JSON.assert(message) 94 | -- LrErrors.throwUserError("Internal Error: " .. message) 95 | -- end 96 | -- 97 | -- If JSON:decode() is passed a nil, this is called instead: 98 | -- 99 | -- JSON:onDecodeOfNilError(message, nil, nil, etc) 100 | -- 101 | -- and if JSON:decode() is passed HTML instead of JSON, this is called: 102 | -- 103 | -- JSON:onDecodeOfHTMLError(message, text, nil, etc) 104 | -- 105 | -- The use of the fourth 'etc' argument allows stronger coordination 106 | -- between decoding and error reporting, especially when you provide your 107 | -- own error-handling routines. Continuing with the the Adobe Lightroom 108 | -- plugin example: 109 | -- 110 | -- function JSON:onDecodeError(message, text, location, etc) 111 | -- local note = "Internal Error: invalid JSON data" 112 | -- if type(etc) = 'table' and etc.photo then 113 | -- note = note .. " while processing for " .. etc.photo:getFormattedMetadata('fileName') 114 | -- end 115 | -- LrErrors.throwUserError(note) 116 | -- end 117 | -- 118 | -- : 119 | -- : 120 | -- 121 | -- for i, photo in ipairs(photosToProcess) do 122 | -- : 123 | -- : 124 | -- local data = JSON:decode(someJsonText, { photo = photo }) 125 | -- : 126 | -- : 127 | -- end 128 | -- 129 | -- 130 | -- 131 | -- 132 | -- 133 | -- DECODING AND STRICT TYPES 134 | -- 135 | -- Because both JSON objects and JSON arrays are converted to Lua tables, 136 | -- it's not normally possible to tell which original JSON type a 137 | -- particular Lua table was derived from, or guarantee decode-encode 138 | -- round-trip equivalency. 139 | -- 140 | -- However, if you enable strictTypes, e.g. 141 | -- 142 | -- JSON = assert(loadfile "JSON.lua")() --load the routines 143 | -- JSON.strictTypes = true 144 | -- 145 | -- then the Lua table resulting from the decoding of a JSON object or 146 | -- JSON array is marked via Lua metatable, so that when re-encoded with 147 | -- JSON:encode() it ends up as the appropriate JSON type. 148 | -- 149 | -- (This is not the default because other routines may not work well with 150 | -- tables that have a metatable set, for example, Lightroom API calls.) 151 | -- 152 | -- 153 | -- ENCODING (from a lua table to a JSON string) 154 | -- 155 | -- JSON = assert(loadfile "JSON.lua")() -- one-time load of the routines 156 | -- 157 | -- local raw_json_text = JSON:encode(lua_table_or_value) 158 | -- local pretty_json_text = JSON:encode_pretty(lua_table_or_value) -- "pretty printed" version for human readability 159 | -- local custom_pretty = JSON:encode(lua_table_or_value, etc, { pretty = true, indent = "| ", align_keys = false }) 160 | -- 161 | -- On error during encoding, this code calls: 162 | -- 163 | -- JSON:onEncodeError(message, etc) 164 | -- 165 | -- which you can override in your local JSON object. 166 | -- 167 | -- The 'etc' in the error call is the second argument to encode() 168 | -- and encode_pretty(), or nil if it wasn't provided. 169 | -- 170 | -- 171 | -- PRETTY-PRINTING 172 | -- 173 | -- An optional third argument, a table of options, allows a bit of 174 | -- configuration about how the encoding takes place: 175 | -- 176 | -- pretty = JSON:encode(val, etc, { 177 | -- pretty = true, -- if false, no other options matter 178 | -- indent = " ", -- this provides for a three-space indent per nesting level 179 | -- align_keys = false, -- see below 180 | -- }) 181 | -- 182 | -- encode() and encode_pretty() are identical except that encode_pretty() 183 | -- provides a default options table if none given in the call: 184 | -- 185 | -- { pretty = true, align_keys = false, indent = " " } 186 | -- 187 | -- For example, if 188 | -- 189 | -- JSON:encode(data) 190 | -- 191 | -- produces: 192 | -- 193 | -- {"city":"Kyoto","climate":{"avg_temp":16,"humidity":"high","snowfall":"minimal"},"country":"Japan","wards":11} 194 | -- 195 | -- then 196 | -- 197 | -- JSON:encode_pretty(data) 198 | -- 199 | -- produces: 200 | -- 201 | -- { 202 | -- "city": "Kyoto", 203 | -- "climate": { 204 | -- "avg_temp": 16, 205 | -- "humidity": "high", 206 | -- "snowfall": "minimal" 207 | -- }, 208 | -- "country": "Japan", 209 | -- "wards": 11 210 | -- } 211 | -- 212 | -- The following three lines return identical results: 213 | -- JSON:encode_pretty(data) 214 | -- JSON:encode_pretty(data, nil, { pretty = true, align_keys = false, indent = " " }) 215 | -- JSON:encode (data, nil, { pretty = true, align_keys = false, indent = " " }) 216 | -- 217 | -- An example of setting your own indent string: 218 | -- 219 | -- JSON:encode_pretty(data, nil, { pretty = true, indent = "| " }) 220 | -- 221 | -- produces: 222 | -- 223 | -- { 224 | -- | "city": "Kyoto", 225 | -- | "climate": { 226 | -- | | "avg_temp": 16, 227 | -- | | "humidity": "high", 228 | -- | | "snowfall": "minimal" 229 | -- | }, 230 | -- | "country": "Japan", 231 | -- | "wards": 11 232 | -- } 233 | -- 234 | -- An example of setting align_keys to true: 235 | -- 236 | -- JSON:encode_pretty(data, nil, { pretty = true, indent = " ", align_keys = true }) 237 | -- 238 | -- produces: 239 | -- 240 | -- { 241 | -- "city": "Kyoto", 242 | -- "climate": { 243 | -- "avg_temp": 16, 244 | -- "humidity": "high", 245 | -- "snowfall": "minimal" 246 | -- }, 247 | -- "country": "Japan", 248 | -- "wards": 11 249 | -- } 250 | -- 251 | -- which I must admit is kinda ugly, sorry. This was the default for 252 | -- encode_pretty() prior to version 20141223.14. 253 | -- 254 | -- 255 | -- AMBIGUOUS SITUATIONS DURING THE ENCODING 256 | -- 257 | -- During the encode, if a Lua table being encoded contains both string 258 | -- and numeric keys, it fits neither JSON's idea of an object, nor its 259 | -- idea of an array. To get around this, when any string key exists (or 260 | -- when non-positive numeric keys exist), numeric keys are converted to 261 | -- strings. 262 | -- 263 | -- For example, 264 | -- JSON:encode({ "one", "two", "three", SOMESTRING = "some string" })) 265 | -- produces the JSON object 266 | -- {"1":"one","2":"two","3":"three","SOMESTRING":"some string"} 267 | -- 268 | -- To prohibit this conversion and instead make it an error condition, set 269 | -- JSON.noKeyConversion = true 270 | -- 271 | 272 | 273 | 274 | 275 | -- 276 | -- SUMMARY OF METHODS YOU CAN OVERRIDE IN YOUR LOCAL LUA JSON OBJECT 277 | -- 278 | -- assert 279 | -- onDecodeError 280 | -- onDecodeOfNilError 281 | -- onDecodeOfHTMLError 282 | -- onEncodeError 283 | -- 284 | -- If you want to create a separate Lua JSON object with its own error handlers, 285 | -- you can reload JSON.lua or use the :new() method. 286 | -- 287 | --------------------------------------------------------------------------- 288 | 289 | local default_pretty_indent = " " 290 | local default_pretty_options = { pretty = true, align_keys = false, indent = default_pretty_indent } 291 | 292 | local isArray = { __tostring = function() return "JSON array" end } isArray.__index = isArray 293 | local isObject = { __tostring = function() return "JSON object" end } isObject.__index = isObject 294 | 295 | 296 | function OBJDEF:newArray(tbl) 297 | return setmetatable(tbl or {}, isArray) 298 | end 299 | 300 | function OBJDEF:newObject(tbl) 301 | return setmetatable(tbl or {}, isObject) 302 | end 303 | 304 | local function unicode_codepoint_as_utf8(codepoint) 305 | -- 306 | -- codepoint is a number 307 | -- 308 | if codepoint <= 127 then 309 | return string.char(codepoint) 310 | 311 | elseif codepoint <= 2047 then 312 | -- 313 | -- 110yyyxx 10xxxxxx <-- useful notation from http://en.wikipedia.org/wiki/Utf8 314 | -- 315 | local highpart = math.floor(codepoint / 0x40) 316 | local lowpart = codepoint - (0x40 * highpart) 317 | return string.char(0xC0 + highpart, 318 | 0x80 + lowpart) 319 | 320 | elseif codepoint <= 65535 then 321 | -- 322 | -- 1110yyyy 10yyyyxx 10xxxxxx 323 | -- 324 | local highpart = math.floor(codepoint / 0x1000) 325 | local remainder = codepoint - 0x1000 * highpart 326 | local midpart = math.floor(remainder / 0x40) 327 | local lowpart = remainder - 0x40 * midpart 328 | 329 | highpart = 0xE0 + highpart 330 | midpart = 0x80 + midpart 331 | lowpart = 0x80 + lowpart 332 | 333 | -- 334 | -- Check for an invalid character (thanks Andy R. at Adobe). 335 | -- See table 3.7, page 93, in http://www.unicode.org/versions/Unicode5.2.0/ch03.pdf#G28070 336 | -- 337 | if ( highpart == 0xE0 and midpart < 0xA0 ) or 338 | ( highpart == 0xED and midpart > 0x9F ) or 339 | ( highpart == 0xF0 and midpart < 0x90 ) or 340 | ( highpart == 0xF4 and midpart > 0x8F ) 341 | then 342 | return "?" 343 | else 344 | return string.char(highpart, 345 | midpart, 346 | lowpart) 347 | end 348 | 349 | else 350 | -- 351 | -- 11110zzz 10zzyyyy 10yyyyxx 10xxxxxx 352 | -- 353 | local highpart = math.floor(codepoint / 0x40000) 354 | local remainder = codepoint - 0x40000 * highpart 355 | local midA = math.floor(remainder / 0x1000) 356 | remainder = remainder - 0x1000 * midA 357 | local midB = math.floor(remainder / 0x40) 358 | local lowpart = remainder - 0x40 * midB 359 | 360 | return string.char(0xF0 + highpart, 361 | 0x80 + midA, 362 | 0x80 + midB, 363 | 0x80 + lowpart) 364 | end 365 | end 366 | 367 | function OBJDEF:onDecodeError(message, text, location, etc) 368 | if text then 369 | if location then 370 | message = string.format("%s at char %d of: %s", message, location, text) 371 | else 372 | message = string.format("%s: %s", message, text) 373 | end 374 | end 375 | 376 | if etc ~= nil then 377 | message = message .. " (" .. OBJDEF:encode(etc) .. ")" 378 | end 379 | 380 | if self.assert then 381 | self.assert(false, message) 382 | else 383 | assert(false, message) 384 | end 385 | end 386 | 387 | OBJDEF.onDecodeOfNilError = OBJDEF.onDecodeError 388 | OBJDEF.onDecodeOfHTMLError = OBJDEF.onDecodeError 389 | 390 | function OBJDEF:onEncodeError(message, etc) 391 | if etc ~= nil then 392 | message = message .. " (" .. OBJDEF:encode(etc) .. ")" 393 | end 394 | 395 | if self.assert then 396 | self.assert(false, message) 397 | else 398 | assert(false, message) 399 | end 400 | end 401 | 402 | local function grok_number(self, text, start, etc) 403 | -- 404 | -- Grab the integer part 405 | -- 406 | local integer_part = text:match('^-?[1-9]%d*', start) 407 | or text:match("^-?0", start) 408 | 409 | if not integer_part then 410 | self:onDecodeError("expected number", text, start, etc) 411 | end 412 | 413 | local i = start + integer_part:len() 414 | 415 | -- 416 | -- Grab an optional decimal part 417 | -- 418 | local decimal_part = text:match('^%.%d+', i) or "" 419 | 420 | i = i + decimal_part:len() 421 | 422 | -- 423 | -- Grab an optional exponential part 424 | -- 425 | local exponent_part = text:match('^[eE][-+]?%d+', i) or "" 426 | 427 | i = i + exponent_part:len() 428 | 429 | local full_number_text = integer_part .. decimal_part .. exponent_part 430 | local as_number = tonumber(full_number_text) 431 | 432 | if not as_number then 433 | self:onDecodeError("bad number", text, start, etc) 434 | end 435 | 436 | return as_number, i 437 | end 438 | 439 | 440 | local function grok_string(self, text, start, etc) 441 | 442 | if text:sub(start,start) ~= '"' then 443 | self:onDecodeError("expected string's opening quote", text, start, etc) 444 | end 445 | 446 | local i = start + 1 -- +1 to bypass the initial quote 447 | local text_len = text:len() 448 | local VALUE = "" 449 | while i <= text_len do 450 | local c = text:sub(i,i) 451 | if c == '"' then 452 | return VALUE, i + 1 453 | end 454 | if c ~= '\\' then 455 | VALUE = VALUE .. c 456 | i = i + 1 457 | elseif text:match('^\\b', i) then 458 | VALUE = VALUE .. "\b" 459 | i = i + 2 460 | elseif text:match('^\\f', i) then 461 | VALUE = VALUE .. "\f" 462 | i = i + 2 463 | elseif text:match('^\\n', i) then 464 | VALUE = VALUE .. "\n" 465 | i = i + 2 466 | elseif text:match('^\\r', i) then 467 | VALUE = VALUE .. "\r" 468 | i = i + 2 469 | elseif text:match('^\\t', i) then 470 | VALUE = VALUE .. "\t" 471 | i = i + 2 472 | else 473 | local hex = text:match('^\\u([0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF])', i) 474 | if hex then 475 | i = i + 6 -- bypass what we just read 476 | 477 | -- We have a Unicode codepoint. It could be standalone, or if in the proper range and 478 | -- followed by another in a specific range, it'll be a two-code surrogate pair. 479 | local codepoint = tonumber(hex, 16) 480 | if codepoint >= 0xD800 and codepoint <= 0xDBFF then 481 | -- it's a hi surrogate... see whether we have a following low 482 | local lo_surrogate = text:match('^\\u([dD][cdefCDEF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF])', i) 483 | if lo_surrogate then 484 | i = i + 6 -- bypass the low surrogate we just read 485 | codepoint = 0x2400 + (codepoint - 0xD800) * 0x400 + tonumber(lo_surrogate, 16) 486 | else 487 | -- not a proper low, so we'll just leave the first codepoint as is and spit it out. 488 | end 489 | end 490 | VALUE = VALUE .. unicode_codepoint_as_utf8(codepoint) 491 | 492 | else 493 | 494 | -- just pass through what's escaped 495 | VALUE = VALUE .. text:match('^\\(.)', i) 496 | i = i + 2 497 | end 498 | end 499 | end 500 | 501 | self:onDecodeError("unclosed string", text, start, etc) 502 | end 503 | 504 | local function skip_whitespace(text, start) 505 | 506 | local _, match_end = text:find("^[ \n\r\t]+", start) -- [http://www.ietf.org/rfc/rfc4627.txt] Section 2 507 | if match_end then 508 | return match_end + 1 509 | else 510 | return start 511 | end 512 | end 513 | 514 | local grok_one -- assigned later 515 | 516 | local function grok_object(self, text, start, etc) 517 | if text:sub(start,start) ~= '{' then 518 | self:onDecodeError("expected '{'", text, start, etc) 519 | end 520 | 521 | local i = skip_whitespace(text, start + 1) -- +1 to skip the '{' 522 | 523 | local VALUE = self.strictTypes and self:newObject { } or { } 524 | 525 | if text:sub(i,i) == '}' then 526 | return VALUE, i + 1 527 | end 528 | local text_len = text:len() 529 | while i <= text_len do 530 | local key, new_i = grok_string(self, text, i, etc) 531 | 532 | i = skip_whitespace(text, new_i) 533 | 534 | if text:sub(i, i) ~= ':' then 535 | self:onDecodeError("expected colon", text, i, etc) 536 | end 537 | 538 | i = skip_whitespace(text, i + 1) 539 | 540 | local new_val, new_i = grok_one(self, text, i) 541 | 542 | VALUE[key] = new_val 543 | 544 | -- 545 | -- Expect now either '}' to end things, or a ',' to allow us to continue. 546 | -- 547 | i = skip_whitespace(text, new_i) 548 | 549 | local c = text:sub(i,i) 550 | 551 | if c == '}' then 552 | return VALUE, i + 1 553 | end 554 | 555 | if text:sub(i, i) ~= ',' then 556 | self:onDecodeError("expected comma or '}'", text, i, etc) 557 | end 558 | 559 | i = skip_whitespace(text, i + 1) 560 | end 561 | 562 | self:onDecodeError("unclosed '{'", text, start, etc) 563 | end 564 | 565 | local function grok_array(self, text, start, etc) 566 | if text:sub(start,start) ~= '[' then 567 | self:onDecodeError("expected '['", text, start, etc) 568 | end 569 | 570 | local i = skip_whitespace(text, start + 1) -- +1 to skip the '[' 571 | local VALUE = self.strictTypes and self:newArray { } or { } 572 | if text:sub(i,i) == ']' then 573 | return VALUE, i + 1 574 | end 575 | 576 | local VALUE_INDEX = 1 577 | 578 | local text_len = text:len() 579 | while i <= text_len do 580 | local val, new_i = grok_one(self, text, i) 581 | 582 | -- can't table.insert(VALUE, val) here because it's a no-op if val is nil 583 | VALUE[VALUE_INDEX] = val 584 | VALUE_INDEX = VALUE_INDEX + 1 585 | 586 | i = skip_whitespace(text, new_i) 587 | 588 | -- 589 | -- Expect now either ']' to end things, or a ',' to allow us to continue. 590 | -- 591 | local c = text:sub(i,i) 592 | if c == ']' then 593 | return VALUE, i + 1 594 | end 595 | if text:sub(i, i) ~= ',' then 596 | self:onDecodeError("expected comma or '['", text, i, etc) 597 | end 598 | i = skip_whitespace(text, i + 1) 599 | end 600 | self:onDecodeError("unclosed '['", text, start, etc) 601 | end 602 | 603 | 604 | grok_one = function(self, text, start, etc) 605 | -- Skip any whitespace 606 | start = skip_whitespace(text, start) 607 | 608 | if start > text:len() then 609 | self:onDecodeError("unexpected end of string", text, nil, etc) 610 | end 611 | 612 | if text:find('^"', start) then 613 | return grok_string(self, text, start, etc) 614 | 615 | elseif text:find('^[-0123456789 ]', start) then 616 | return grok_number(self, text, start, etc) 617 | 618 | elseif text:find('^%{', start) then 619 | return grok_object(self, text, start, etc) 620 | 621 | elseif text:find('^%[', start) then 622 | return grok_array(self, text, start, etc) 623 | 624 | elseif text:find('^true', start) then 625 | return true, start + 4 626 | 627 | elseif text:find('^false', start) then 628 | return false, start + 5 629 | 630 | elseif text:find('^null', start) then 631 | return nil, start + 4 632 | 633 | else 634 | self:onDecodeError("can't parse JSON", text, start, etc) 635 | end 636 | end 637 | 638 | function OBJDEF:decode(text, etc) 639 | if type(self) ~= 'table' or self.__index ~= OBJDEF then 640 | OBJDEF:onDecodeError("JSON:decode must be called in method format", nil, nil, etc) 641 | end 642 | 643 | if text == nil then 644 | self:onDecodeOfNilError(string.format("nil passed to JSON:decode()"), nil, nil, etc) 645 | elseif type(text) ~= 'string' then 646 | self:onDecodeError(string.format("expected string argument to JSON:decode(), got %s", type(text)), nil, nil, etc) 647 | end 648 | 649 | if text:match('^%s*$') then 650 | return nil 651 | end 652 | 653 | if text:match('^%s*<') then 654 | -- Can't be JSON... we'll assume it's HTML 655 | self:onDecodeOfHTMLError(string.format("html passed to JSON:decode()"), text, nil, etc) 656 | end 657 | 658 | -- 659 | -- Ensure that it's not UTF-32 or UTF-16. 660 | -- Those are perfectly valid encodings for JSON (as per RFC 4627 section 3), 661 | -- but this package can't handle them. 662 | -- 663 | if text:sub(1,1):byte() == 0 or (text:len() >= 2 and text:sub(2,2):byte() == 0) then 664 | self:onDecodeError("JSON package groks only UTF-8, sorry", text, nil, etc) 665 | end 666 | 667 | local success, value = pcall(grok_one, self, text, 1, etc) 668 | 669 | if success then 670 | return value 671 | else 672 | -- if JSON:onDecodeError() didn't abort out of the pcall, we'll have received the error message here as "value", so pass it along as an assert. 673 | if self.assert then 674 | self.assert(false, value) 675 | else 676 | assert(false, value) 677 | end 678 | -- and if we're still here, return a nil and throw the error message on as a second arg 679 | return nil, value 680 | end 681 | end 682 | 683 | local function backslash_replacement_function(c) 684 | if c == "\n" then 685 | return "\\n" 686 | elseif c == "\r" then 687 | return "\\r" 688 | elseif c == "\t" then 689 | return "\\t" 690 | elseif c == "\b" then 691 | return "\\b" 692 | elseif c == "\f" then 693 | return "\\f" 694 | elseif c == '"' then 695 | return '\\"' 696 | elseif c == '\\' then 697 | return '\\\\' 698 | else 699 | return string.format("\\u%04x", c:byte()) 700 | end 701 | end 702 | 703 | local chars_to_be_escaped_in_JSON_string 704 | = '[' 705 | .. '"' -- class sub-pattern to match a double quote 706 | .. '%\\' -- class sub-pattern to match a backslash 707 | .. '%z' -- class sub-pattern to match a null 708 | .. '\001' .. '-' .. '\031' -- class sub-pattern to match control characters 709 | .. ']' 710 | 711 | local function json_string_literal(value) 712 | local newval = value:gsub(chars_to_be_escaped_in_JSON_string, backslash_replacement_function) 713 | return '"' .. newval .. '"' 714 | end 715 | 716 | local function object_or_array(self, T, etc) 717 | -- 718 | -- We need to inspect all the keys... if there are any strings, we'll convert to a JSON 719 | -- object. If there are only numbers, it's a JSON array. 720 | -- 721 | -- If we'll be converting to a JSON object, we'll want to sort the keys so that the 722 | -- end result is deterministic. 723 | -- 724 | local string_keys = { } 725 | local number_keys = { } 726 | local number_keys_must_be_strings = false 727 | local maximum_number_key 728 | 729 | for key in pairs(T) do 730 | if type(key) == 'string' then 731 | table.insert(string_keys, key) 732 | elseif type(key) == 'number' then 733 | table.insert(number_keys, key) 734 | if key <= 0 or key >= math.huge then 735 | number_keys_must_be_strings = true 736 | elseif not maximum_number_key or key > maximum_number_key then 737 | maximum_number_key = key 738 | end 739 | else 740 | self:onEncodeError("can't encode table with a key of type " .. type(key), etc) 741 | end 742 | end 743 | 744 | if #string_keys == 0 and not number_keys_must_be_strings then 745 | -- 746 | -- An empty table, or a numeric-only array 747 | -- 748 | if #number_keys > 0 then 749 | return nil, maximum_number_key -- an array 750 | elseif tostring(T) == "JSON array" then 751 | return nil 752 | elseif tostring(T) == "JSON object" then 753 | return { } 754 | else 755 | -- have to guess, so we'll pick array, since empty arrays are likely more common than empty objects 756 | return nil 757 | end 758 | end 759 | 760 | table.sort(string_keys) 761 | 762 | local map 763 | if #number_keys > 0 then 764 | -- 765 | -- If we're here then we have either mixed string/number keys, or numbers inappropriate for a JSON array 766 | -- It's not ideal, but we'll turn the numbers into strings so that we can at least create a JSON object. 767 | -- 768 | 769 | if self.noKeyConversion then 770 | self:onEncodeError("a table with both numeric and string keys could be an object or array; aborting", etc) 771 | end 772 | 773 | -- 774 | -- Have to make a shallow copy of the source table so we can remap the numeric keys to be strings 775 | -- 776 | map = { } 777 | for key, val in pairs(T) do 778 | map[key] = val 779 | end 780 | 781 | table.sort(number_keys) 782 | 783 | -- 784 | -- Throw numeric keys in there as strings 785 | -- 786 | for _, number_key in ipairs(number_keys) do 787 | local string_key = tostring(number_key) 788 | if map[string_key] == nil then 789 | table.insert(string_keys , string_key) 790 | map[string_key] = T[number_key] 791 | else 792 | self:onEncodeError("conflict converting table with mixed-type keys into a JSON object: key " .. number_key .. " exists both as a string and a number.", etc) 793 | end 794 | end 795 | end 796 | 797 | return string_keys, nil, map 798 | end 799 | 800 | -- 801 | -- Encode 802 | -- 803 | -- 'options' is nil, or a table with possible keys: 804 | -- pretty -- if true, return a pretty-printed version 805 | -- indent -- a string (usually of spaces) used to indent each nested level 806 | -- align_keys -- if true, align all the keys when formatting a table 807 | -- 808 | local encode_value -- must predeclare because it calls itself 809 | function encode_value(self, value, parents, etc, options, indent) 810 | 811 | if value == nil then 812 | return 'null' 813 | 814 | elseif type(value) == 'string' then 815 | return json_string_literal(value) 816 | 817 | elseif type(value) == 'number' then 818 | if value ~= value then 819 | -- 820 | -- NaN (Not a Number). 821 | -- JSON has no NaN, so we have to fudge the best we can. This should really be a package option. 822 | -- 823 | return "null" 824 | elseif value >= math.huge then 825 | -- 826 | -- Positive infinity. JSON has no INF, so we have to fudge the best we can. This should 827 | -- really be a package option. Note: at least with some implementations, positive infinity 828 | -- is both ">= math.huge" and "<= -math.huge", which makes no sense but that's how it is. 829 | -- Negative infinity is properly "<= -math.huge". So, we must be sure to check the ">=" 830 | -- case first. 831 | -- 832 | return "1e+9999" 833 | elseif value <= -math.huge then 834 | -- 835 | -- Negative infinity. 836 | -- JSON has no INF, so we have to fudge the best we can. This should really be a package option. 837 | -- 838 | return "-1e+9999" 839 | else 840 | return tostring(value) 841 | end 842 | 843 | elseif type(value) == 'boolean' then 844 | return tostring(value) 845 | 846 | elseif type(value) ~= 'table' then 847 | self:onEncodeError("can't convert " .. type(value) .. " to JSON", etc) 848 | 849 | else 850 | -- 851 | -- A table to be converted to either a JSON object or array. 852 | -- 853 | local T = value 854 | 855 | if type(options) ~= 'table' then 856 | options = {} 857 | end 858 | if type(indent) ~= 'string' then 859 | indent = "" 860 | end 861 | 862 | if parents[T] then 863 | self:onEncodeError("table " .. tostring(T) .. " is a child of itself", etc) 864 | else 865 | parents[T] = true 866 | end 867 | 868 | local result_value 869 | 870 | local object_keys, maximum_number_key, map = object_or_array(self, T, etc) 871 | if maximum_number_key then 872 | -- 873 | -- An array... 874 | -- 875 | local ITEMS = { } 876 | for i = 1, maximum_number_key do 877 | table.insert(ITEMS, encode_value(self, T[i], parents, etc, options, indent)) 878 | end 879 | 880 | if options.pretty then 881 | result_value = "[ " .. table.concat(ITEMS, ", ") .. " ]" 882 | else 883 | result_value = "[" .. table.concat(ITEMS, ",") .. "]" 884 | end 885 | 886 | elseif object_keys then 887 | -- 888 | -- An object 889 | -- 890 | local TT = map or T 891 | 892 | if options.pretty then 893 | 894 | local KEYS = { } 895 | local max_key_length = 0 896 | for _, key in ipairs(object_keys) do 897 | local encoded = encode_value(self, tostring(key), parents, etc, options, indent) 898 | if options.align_keys then 899 | max_key_length = math.max(max_key_length, #encoded) 900 | end 901 | table.insert(KEYS, encoded) 902 | end 903 | local key_indent = indent .. tostring(options.indent or "") 904 | local subtable_indent = key_indent .. string.rep(" ", max_key_length) .. (options.align_keys and " " or "") 905 | local FORMAT = "%s%" .. string.format("%d", max_key_length) .. "s: %s" 906 | 907 | local COMBINED_PARTS = { } 908 | for i, key in ipairs(object_keys) do 909 | local encoded_val = encode_value(self, TT[key], parents, etc, options, subtable_indent) 910 | table.insert(COMBINED_PARTS, string.format(FORMAT, key_indent, KEYS[i], encoded_val)) 911 | end 912 | result_value = "{\n" .. table.concat(COMBINED_PARTS, ",\n") .. "\n" .. indent .. "}" 913 | 914 | else 915 | 916 | local PARTS = { } 917 | for _, key in ipairs(object_keys) do 918 | local encoded_val = encode_value(self, TT[key], parents, etc, options, indent) 919 | local encoded_key = encode_value(self, tostring(key), parents, etc, options, indent) 920 | table.insert(PARTS, string.format("%s:%s", encoded_key, encoded_val)) 921 | end 922 | result_value = "{" .. table.concat(PARTS, ",") .. "}" 923 | 924 | end 925 | else 926 | -- 927 | -- An empty array/object... we'll treat it as an array, though it should really be an option 928 | -- 929 | result_value = "[]" 930 | end 931 | 932 | parents[T] = false 933 | return result_value 934 | end 935 | end 936 | 937 | 938 | function OBJDEF:encode(value, etc, options) 939 | if type(self) ~= 'table' or self.__index ~= OBJDEF then 940 | OBJDEF:onEncodeError("JSON:encode must be called in method format", etc) 941 | end 942 | return encode_value(self, value, {}, etc, options or nil) 943 | end 944 | 945 | function OBJDEF:encode_pretty(value, etc, options) 946 | if type(self) ~= 'table' or self.__index ~= OBJDEF then 947 | OBJDEF:onEncodeError("JSON:encode_pretty must be called in method format", etc) 948 | end 949 | return encode_value(self, value, {}, etc, options or default_pretty_options) 950 | end 951 | 952 | function OBJDEF.__tostring() 953 | return "JSON encode/decode package" 954 | end 955 | 956 | OBJDEF.__index = OBJDEF 957 | 958 | function OBJDEF:new(args) 959 | local new = { } 960 | 961 | if args then 962 | for key, val in pairs(args) do 963 | new[key] = val 964 | end 965 | end 966 | 967 | return setmetatable(new, OBJDEF) 968 | end 969 | 970 | return OBJDEF:new() 971 | 972 | -- 973 | -- Version history: 974 | -- 975 | -- 20141223.14 The encode_pretty() routine produced fine results for small datasets, but isn't really 976 | -- appropriate for anything large, so with help from Alex Aulbach I've made the encode routines 977 | -- more flexible, and changed the default encode_pretty() to be more generally useful. 978 | -- 979 | -- Added a third 'options' argument to the encode() and encode_pretty() routines, to control 980 | -- how the encoding takes place. 981 | -- 982 | -- Updated docs to add assert() call to the loadfile() line, just as good practice so that 983 | -- if there is a problem loading JSON.lua, the appropriate error message will percolate up. 984 | -- 985 | -- 20140920.13 Put back (in a way that doesn't cause warnings about unused variables) the author string, 986 | -- so that the source of the package, and its version number, are visible in compiled copies. 987 | -- 988 | -- 20140911.12 Minor lua cleanup. 989 | -- Fixed internal reference to 'JSON.noKeyConversion' to reference 'self' instead of 'JSON'. 990 | -- (Thanks to SmugMug's David Parry for these.) 991 | -- 992 | -- 20140418.11 JSON nulls embedded within an array were being ignored, such that 993 | -- ["1",null,null,null,null,null,"seven"], 994 | -- would return 995 | -- {1,"seven"} 996 | -- It's now fixed to properly return 997 | -- {1, nil, nil, nil, nil, nil, "seven"} 998 | -- Thanks to "haddock" for catching the error. 999 | -- 1000 | -- 20140116.10 The user's JSON.assert() wasn't always being used. Thanks to "blue" for the heads up. 1001 | -- 1002 | -- 20131118.9 Update for Lua 5.3... it seems that tostring(2/1) produces "2.0" instead of "2", 1003 | -- and this caused some problems. 1004 | -- 1005 | -- 20131031.8 Unified the code for encode() and encode_pretty(); they had been stupidly separate, 1006 | -- and had of course diverged (encode_pretty didn't get the fixes that encode got, so 1007 | -- sometimes produced incorrect results; thanks to Mattie for the heads up). 1008 | -- 1009 | -- Handle encoding tables with non-positive numeric keys (unlikely, but possible). 1010 | -- 1011 | -- If a table has both numeric and string keys, or its numeric keys are inappropriate 1012 | -- (such as being non-positive or infinite), the numeric keys are turned into 1013 | -- string keys appropriate for a JSON object. So, as before, 1014 | -- JSON:encode({ "one", "two", "three" }) 1015 | -- produces the array 1016 | -- ["one","two","three"] 1017 | -- but now something with mixed key types like 1018 | -- JSON:encode({ "one", "two", "three", SOMESTRING = "some string" })) 1019 | -- instead of throwing an error produces an object: 1020 | -- {"1":"one","2":"two","3":"three","SOMESTRING":"some string"} 1021 | -- 1022 | -- To maintain the prior throw-an-error semantics, set 1023 | -- JSON.noKeyConversion = true 1024 | -- 1025 | -- 20131004.7 Release under a Creative Commons CC-BY license, which I should have done from day one, sorry. 1026 | -- 1027 | -- 20130120.6 Comment update: added a link to the specific page on my blog where this code can 1028 | -- be found, so that folks who come across the code outside of my blog can find updates 1029 | -- more easily. 1030 | -- 1031 | -- 20111207.5 Added support for the 'etc' arguments, for better error reporting. 1032 | -- 1033 | -- 20110731.4 More feedback from David Kolf on how to make the tests for Nan/Infinity system independent. 1034 | -- 1035 | -- 20110730.3 Incorporated feedback from David Kolf at http://lua-users.org/wiki/JsonModules: 1036 | -- 1037 | -- * When encoding lua for JSON, Sparse numeric arrays are now handled by 1038 | -- spitting out full arrays, such that 1039 | -- JSON:encode({"one", "two", [10] = "ten"}) 1040 | -- returns 1041 | -- ["one","two",null,null,null,null,null,null,null,"ten"] 1042 | -- 1043 | -- In 20100810.2 and earlier, only up to the first non-null value would have been retained. 1044 | -- 1045 | -- * When encoding lua for JSON, numeric value NaN gets spit out as null, and infinity as "1+e9999". 1046 | -- Version 20100810.2 and earlier created invalid JSON in both cases. 1047 | -- 1048 | -- * Unicode surrogate pairs are now detected when decoding JSON. 1049 | -- 1050 | -- 20100810.2 added some checking to ensure that an invalid Unicode character couldn't leak in to the UTF-8 encoding 1051 | -- 1052 | -- 20100731.1 initial public release 1053 | -- 1054 | -------------------------------------------------------------------------------- /conky/brightnesslevel.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | current_brig=`pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness` 4 | max_brig=`pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-max-brightness` 5 | percent=`echo $current_brig*100/$max_brig| bc` 6 | 7 | case "$1" in 8 | "get") 9 | echo "$percent%" 10 | ;; 11 | "set") 12 | pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness $2 13 | ;; 14 | *) 15 | echo "Usage: $0 {set|get}" 16 | exit 2 17 | esac 18 | 19 | exit 0 20 | -------------------------------------------------------------------------------- /conky/conky-i3bar: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Send the header so that i3bar knows we want to use JSON: 4 | echo '{ "version": 1 }' 5 | 6 | # Begin the endless array. 7 | echo '[' 8 | 9 | # We send an empty first array of blocks to make the loop simpler: 10 | echo '[],' 11 | 12 | # Now send blocks with information forever: 13 | exec conky -c $HOME/.i3/conky/conky.lua 14 | -------------------------------------------------------------------------------- /conky/conky.conf: -------------------------------------------------------------------------------- 1 | ### Conky configuration file 2 | ## Output is printed to the console -> i3bar 3 | 4 | ## No output to X 5 | out_to_x no 6 | 7 | ## Create own window to draw 8 | own_window no 9 | 10 | ## Print everything to console? 11 | out_to_console yes 12 | 13 | ## Use double buffering (reduces flicker, not needed for console output) 14 | double_buffer no 15 | 16 | ## Set to yes if you want Conky to be forked in the background 17 | background no 18 | 19 | ## Update interval in seconds 20 | update_interval 2 21 | 22 | ## This is the number of times Conky will update before quitting. 23 | ## Set to zero to run forever. 24 | total_run_times 0 25 | 26 | ## Shortens units to a single character (kiB->k, GiB->G, etc.). Default is off. 27 | short_units true 28 | 29 | ## How strict should if_up be when testing an interface for being up? 30 | ## The value is one of up, link or address, to check for the interface 31 | ## being solely up, being up and having link or being up, having link 32 | ## and an assigned IP address. 33 | if_up_strictness address 34 | 35 | ## Add spaces to keep things from moving about? This only affects certain objects. 36 | ## use_spacer should have an argument of left, right, or none 37 | use_spacer none 38 | 39 | ## Force UTF8? note that UTF8 support required XFT 40 | override_utf8_locale no 41 | 42 | ## number of cpu samples to average 43 | ## set to 1 to disable averaging 44 | cpu_avg_samples 2 45 | 46 | pad_percents 2 47 | 48 | template0 ${color0}\1 ${exec ~/.i3/conky/info.py \2} 49 | 50 | default_color white 51 | default_shade_color black 52 | default_outline_color white 53 | 54 | ## Stuff after 'TEXT' will be formatted on screen 55 | TEXT 56 | 57 | # JSON for i3bar 58 | [ 59 | # { 60 | # "full_text": "${exec xprop -id $(xdotool getactivewindow) | grep _NET_WM_NAME | cut -d '"' -f2- | sed 's/"$//' | cut -c-20}", 61 | # "color": "\#000000", 62 | # "background": "\#FFFFFF", 63 | # "min_width": "here's a veeeeeeeeeeeeeeeeeeeery long title", 64 | # "align": "center" 65 | # }, 66 | ${if_match ${battery_percent BAT0} <= 10 } 67 | { 68 | "full_text": "Plug In Charger!!!", 69 | "urgent": true, 70 | "color": "\#FF0000" 71 | }, 72 | ${endif} 73 | ${if_match "${exec xset q | grep 'Caps Lock' | sed 's/.*Caps Lock:[ ]*\([^ ]*\).*/\1/'}"=="on"} 74 | { 75 | "full_text": "CapsLock", 76 | "color": "\#00FF00" 77 | }, 78 | ${endif} 79 | # { 80 | # "full_text": "${exec whoami}@${nodename} " 81 | # }, 82 | ${if_up tun0} 83 | { 84 | "full_text": " ${addr tun0}", 85 | "color": "\#00FF00" 86 | }, 87 | ${endif} 88 | { 89 | "full_text": "  ${exec curl icanhazip.com} ", 90 | "border": "\#cccccc", 91 | "background": "\#000000", 92 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 93 | "separator": false, 94 | "separator_block_width": 3 95 | }, 96 | ${if_up eth0} 97 | { 98 | "full_text": "🖧 ${addr eth0} ", 99 | "border": "\#cccccc", 100 | "background": "\#000000", 101 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 102 | "separator": false, 103 | "separator_block_width": 3 104 | }, 105 | ${endif} 106 | ${if_up wlan0} 107 | { 108 | "full_text": "  ${addr wlan0} ", 109 | "border": "\#cccccc", 110 | "background": "\#000000", 111 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 112 | "separator": false, 113 | "separator_block_width": 3 114 | }, 115 | ${endif} 116 | # { 117 | # "full_text": " D: ${downspeed eth0}/s U: ${upspeed eth0}/s T: ${totaldown eth0}" 118 | # }, 119 | # { 120 | # "full_text": " CPU: ${cpu cpu0}% ", 121 | # "color": ${if_match ${cpu cpu0}>90}"\#FF0000"${else}${if_match ${cpu cpu0}<10}"\#00CC00"${else}"\#ffffff"${endif}${endif} 122 | # }, 123 | { 124 | "full_text": "  / ${fs_free} (${fs_free_perc /}%) ", 125 | "separator": false, 126 | "background": "\#000000", 127 | "separator_block_width": 3, 128 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 129 | ${if_match ${fs_free_perc /}>=30} 130 | "border": "\#cccccc" 131 | ${endif} 132 | ${if_match ${fs_free_perc /}<30} 133 | ${if_match ${fs_free_perc /}>=20} 134 | "border": "\#ffff99" # yellow 135 | ${endif} 136 | ${endif} 137 | ${if_match ${fs_free_perc /}<20} 138 | ${if_match ${fs_free_perc /}>=10} 139 | "border": "\#ff9933" # orange 140 | ${endif} 141 | ${endif} 142 | ${if_match ${fs_free_perc /}<10} 143 | "color": "\#ff0000", # red 144 | "border": "\#ff0000" # red 145 | ${endif} 146 | }, 147 | {\ 148 | "full_text": "  /home ${fs_free /home} (${fs_free_perc /home}%) ",\ 149 | "background": "\#000000", 150 | "separator": false,\ 151 | "separator_block_width": 3,\ 152 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2,\ 153 | ${if_match ${fs_free_perc /home}>=30}\ 154 | # green 155 | "border": "\#cccccc"\ 156 | ${endif}\ 157 | ${if_match ${fs_free_perc /home}<30}\ 158 | ${if_match ${fs_free_perc /home}>=20}\ 159 | # yellow 160 | "border": "\#ffff99"\ 161 | ${endif}\ 162 | ${endif}\ 163 | ${if_match ${fs_free_perc /home}<20}\ 164 | ${if_match ${fs_free_perc /home}>=10}\ 165 | # orange 166 | "border": "\#ff9933"\ 167 | ${endif}\ 168 | ${endif}\ 169 | ${if_match ${fs_free_perc /home}<10} 170 | # red 171 | "color": "\#ff0000", # red 172 | "border": "\#ff0000"\ 173 | ${endif} 174 | }, 175 | { 176 | "full_text": "  ${memperc}% ", 177 | "background": "\#000000", 178 | "separator": false, 179 | "separator_block_width": 3, 180 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2,\ 181 | ${if_match ${memperc}>=80}\ 182 | # red 183 | "color": "\#ff0000", # red 184 | "border": "\#ff0000"\ 185 | ${endif}\ 186 | ${if_match ${memperc}<80}\ 187 | ${if_match ${memperc}>=70}\ 188 | # orange 189 | "border": "\#ff9933"\ 190 | ${endif}\ 191 | ${endif}\ 192 | ${if_match ${memperc}<70}\ 193 | ${if_match ${memperc}>=60}\ 194 | # yellow 195 | "border": "\#ffff99"\ 196 | ${endif}\ 197 | ${endif}\ 198 | ${if_match ${memperc}<60} 199 | # green 200 | "border": "\#cccccc"\ 201 | ${endif} 202 | }, 203 | { 204 | "full_text": "  ${exec sensors acpitz-virtual-0 | grep 'temp2' | awk '{print $2}'} ", 205 | "border": "\#cccccc", 206 | "background": "\#000000", 207 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 208 | "separator": false, 209 | "separator_block_width": 3 210 | }, 211 | { 212 | "full_text": " 🍥 ${exec sensors asus-isa-0000 | grep 'cpu_fan' | awk '{print $2$3}'} ", 213 | "border": "\#cccccc", 214 | "background": "\#000000", 215 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 216 | "separator": false, 217 | "separator_block_width": 3 218 | }, 219 | { 220 | "full_text": "  ${uptime_short} ", 221 | "min_width": "59m59s", 222 | "border": "\#cccccc", 223 | "background": "\#000000", 224 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 225 | "separator": false, 226 | "separator_block_width": 3 227 | }, 228 | { 229 | "full_text": " ♪ ${exec ~/.i3/conky/volumelevel.sh}% ", 230 | "color": ${if_empty ${exec ~/.i3/conky/volumelevel.sh | grep 'Mute'}}"\#cccccc"${else}"\#ffff00"${endif}, 231 | "border": "\#cccccc", 232 | "background": "\#000000", 233 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 234 | "separator": false, 235 | "separator_block_width": 3 236 | }, 237 | # { "full_text": "${template0  --get-brightness}"}, 238 | { 239 | "full_text": " ${template0  --get-keyboard-layout} ", 240 | "border": "\#cccccc", 241 | "background": "\#000000", 242 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 243 | "separator": false, 244 | "separator_block_width": 3 245 | }, 246 | { 247 | "full_text": " ${if_empty ${exec cat /sys/class/power_supply/BAT0/status | grep 'Discharging'}} ${else}${endif} ${execi 200 ~/.i3/conky/info.py --battery} ", 248 | # " ${battery_bar 6,60 BAT0}" 249 | "background": "\#000000", 250 | "separator": false, 251 | "separator_block_width": 3, 252 | "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2, 253 | ${if_empty ${exec cat /sys/class/power_supply/BAT0/status | grep 'Discharging'}} 254 | "border": "\#cccccc" 255 | ${else} 256 | ${if_match ${battery_percent}>=80} 257 | "border": "\#00FF00" # green 258 | ${endif} 259 | ${if_match ${battery_percent}<80} 260 | ${if_match ${battery_percent}>=50} 261 | "border": "\#ffff99" # yellow 262 | ${endif} 263 | ${endif} 264 | ${if_match ${battery_percent}<50} 265 | ${if_match ${battery_percent}>=20} 266 | "border": "\#ff9933" # orange 267 | ${endif} 268 | ${endif} 269 | ${if_match ${battery_percent}<20} 270 | "color": "\#ff0000", # red 271 | "border": "\#ff0000" # red 272 | ${endif} 273 | ${endif} 274 | }, 275 | # ${if_match ${exec /usr/lib/update-notifier/update-motd-updates-available | grep 'security' | awk '{print $1}'}>0} 276 | # { 277 | # "full_text": "⚠ ${exec /usr/lib/update-notifier/update-motd-updates-available | grep 'security' | awk '{print $1}'} security updates", 278 | # "color": "\#ff0000", # red 279 | # "border": "\#ff0000", # red 280 | # "background": "\#000000", 281 | # "separator_block_width": 3, 282 | # "border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2 283 | # }, 284 | { 285 | "full_text": " ${time %a %d/%m/%y} - ${time %H:%M}" 286 | } 287 | # ##{ "full_text": "${execi 300 ~/.i3/conky/weather.sh} " }, 288 | ], 289 | 290 | -------------------------------------------------------------------------------- /conky/conky.lua: -------------------------------------------------------------------------------- 1 | conky.config = { 2 | -- Conky configuration file 3 | -- Output is printed to the console -> i3bar 4 | 5 | --# No output to X 6 | out_to_x = false, 7 | 8 | --# Create own window to draw 9 | own_window = false, 10 | 11 | --# Print everything to console? 12 | out_to_console = true, 13 | 14 | --# Use double buffering (reduces flicker, not needed for console output) 15 | double_buffer = false, 16 | 17 | --# Set to yes if you want Conky to be forked in the background 18 | background = false, 19 | 20 | --# Update interval in seconds 21 | update_interval = 2, 22 | 23 | --# This is the number of times Conky will update before quitting. 24 | --# Set to zero to run forever. 25 | total_run_times = 0, 26 | 27 | --# Shortens units to a single character (kiB->k, GiB->G, etc.). Default is off. 28 | short_units = true, 29 | 30 | --# How strict should if_up be when testing an interface for being up? 31 | --# The value is one of up, link or address, to check for the interface 32 | --# being solely up, being up and having link or being up, having link 33 | --# and an assigned IP address. 34 | if_up_strictness = 'address', 35 | 36 | --# Add spaces to keep things from moving about? This only affects certain objects. 37 | --# use_spacer should have an argument of left, right, or none 38 | use_spacer = 'none', 39 | 40 | --# Force UTF8? note that UTF8 support required XFT 41 | override_utf8_locale = false, 42 | 43 | --# number of cpu samples to average 44 | --# set to 1 to disable averaging 45 | cpu_avg_samples = 2, 46 | 47 | pad_percents = 2, 48 | 49 | color0 = '#cccccc', 50 | template0 = [["border_bottom": 2, "border_top": 0, "border_left": 0, "border_right": 2]], 51 | 52 | 53 | default_color = 'white', 54 | default_shade_color = 'black', 55 | default_outline_color = 'white', 56 | 57 | --# Stuff after 'TEXT' will be formatted on screen 58 | }; 59 | 60 | conky.text = [[ 61 | 62 | # JSON for i3bar 63 | [ 64 | # { 65 | # "full_text": "${exec xprop -id $(xdotool getactivewindow) | grep _NET_WM_NAME | cut -d '"' -f2- | sed 's/"$//' | cut -c-20}", 66 | # "color": "\#000000", 67 | # "background": "\#FFFFFF", 68 | # "min_width": "here's a veeeeeeeeeeeeeeeeeeeery long title", 69 | # "align": "center" 70 | # }, 71 | ${if_empty ${exec cat /sys/class/power_supply/BAT0/status | grep 'Charging'}} 72 | ${if_match ${battery_percent BAT0} <= 10 } 73 | { 74 | "full_text": "Plug In Charger!!!", 75 | "urgent": true, 76 | "color": "\#FF0000" 77 | }, 78 | ${endif} 79 | ${endif} 80 | ${if_match "${exec xset q | grep 'Caps Lock' | sed 's/.*Caps Lock:[ ]*\([^ ]*\).*/\1/'}"=="on"} 81 | { 82 | "full_text": "CapsLock", 83 | "color": "\#00FF00" 84 | }, 85 | ${endif} 86 | # { 87 | # "full_text": "${exec whoami}@${nodename} " 88 | # }, 89 | ${if_up vpn0} 90 | { 91 | "full_text": "  ${addr vpn0}", 92 | "color": "\#00FF00" 93 | }, 94 | ${if_up tun0} 95 | { 96 | "full_text": "  ${addr tun0}", 97 | "color": "\#00FF00" 98 | }, 99 | ${endif} 100 | # { 101 | # "full_text": "  ${exec curl icanhazip.com} ", 102 | # "border": "\#cccccc", 103 | # ${template0}, 104 | # "separator": false, 105 | # "separator_block_width": 3 106 | # }, 107 | ${if_up eth0} 108 | { 109 | "full_text": " 🜷 ${addr eth0} ", 110 | "border": "\#cccccc", 111 | ${template0}, 112 | "separator": false, 113 | "separator_block_width": 3 114 | }, 115 | ${endif} 116 | ${if_up wlan0} 117 | { 118 | "full_text": "  ${addr wlan0} ", 119 | "border": "\#cccccc", 120 | ${template0}, 121 | "separator": false, 122 | "separator_block_width": 3 123 | }, 124 | ${endif} 125 | # { 126 | # "full_text": " D: ${downspeed eth0}/s U: ${upspeed eth0}/s T: ${totaldown eth0}" 127 | # }, 128 | # { 129 | # "full_text": " CPU: ${cpu cpu0}% ", 130 | # "color": ${if_match ${cpu cpu0}>90}"\#FF0000"${else}${if_match ${cpu cpu0}<10}"\#00CC00"${else}"\#ffffff"${endif}${endif} 131 | # }, 132 | { 133 | "full_text": "  / ${fs_free} (${fs_free_perc /}%) ", 134 | "separator": false, 135 | "separator_block_width": 3, 136 | ${template0}, 137 | ${if_match ${fs_free_perc /}>=30} 138 | "border": "\#cccccc" 139 | ${endif} 140 | ${if_match ${fs_free_perc /}<30} 141 | ${if_match ${fs_free_perc /}>=20} 142 | "border": "\#ffff99" # yellow 143 | ${endif} 144 | ${endif} 145 | ${if_match ${fs_free_perc /}<20} 146 | ${if_match ${fs_free_perc /}>=10} 147 | "border": "\#ff9933" # orange 148 | ${endif} 149 | ${endif} 150 | ${if_match ${fs_free_perc /}<10} 151 | "color": "\#ff0000", # red 152 | "border": "\#ff0000" # red 153 | ${endif} 154 | }, 155 | { 156 | "full_text": "  /home ${fs_free /home} (${fs_free_perc /home}%) ", 157 | "separator": false, 158 | "separator_block_width": 3, 159 | ${template0}, 160 | ${if_match ${fs_free_perc /home}>=30} 161 | "border": "\#cccccc" 162 | ${endif} 163 | ${if_match ${fs_free_perc /home}<30} 164 | ${if_match ${fs_free_perc /home}>=20} 165 | "border": "\#ffff99" 166 | ${endif} 167 | ${endif} 168 | ${if_match ${fs_free_perc /home}<20} 169 | ${if_match ${fs_free_perc /home}>=10} 170 | "border": "\#ff9933" 171 | ${endif} 172 | ${endif} 173 | ${if_match ${fs_free_perc /home}<10} 174 | "color": "\#ff0000", 175 | "border": "\#ff0000" 176 | ${endif} 177 | }, 178 | { 179 | "full_text": "  ${memperc}% ", 180 | "separator": false, 181 | "separator_block_width": 3, 182 | ${template0}, 183 | ${if_match ${memperc}>=80} 184 | # red 185 | "color": "\#ff0000", # red 186 | "border": "\#ff0000" 187 | ${endif} 188 | ${if_match ${memperc}<80} 189 | ${if_match ${memperc}>=70} 190 | # orange 191 | "border": "\#ff9933" 192 | ${endif} 193 | ${endif} 194 | ${if_match ${memperc}<70} 195 | ${if_match ${memperc}>=60} 196 | # yellow 197 | "border": "\#ffff99" 198 | ${endif} 199 | ${endif} 200 | ${if_match ${memperc}<60} 201 | # green 202 | "border": "\#cccccc" 203 | ${endif} 204 | }, 205 | { 206 | "full_text": "  ${exec sensors acpitz-virtual-0 | grep 'temp2' | awk '{print $2}'} ", 207 | "border": "\#cccccc", 208 | ${template0}, 209 | "separator": false, 210 | "separator_block_width": 3 211 | }, 212 | { 213 | "full_text": " 🍥 ${exec sensors asus-isa-0000 | grep 'cpu_fan' | awk '{print $2$3}'} ", 214 | "border": "\#cccccc", 215 | ${template0}, 216 | "separator": false, 217 | "separator_block_width": 3 218 | }, 219 | { 220 | "full_text": "  ${uptime_short} ", 221 | "min_width": "59m59s", 222 | "border": "\#cccccc", 223 | ${template0}, 224 | "separator": false, 225 | "separator_block_width": 3 226 | }, 227 | { 228 | "full_text": " ♪ ${exec ~/.i3/conky/volumelevel.sh}% ", 229 | "color": ${if_empty ${exec ~/.i3/conky/volumelevel.sh | grep 'Mute'}}"\#cccccc"${else}"\#ffff00"${endif}, 230 | "border": "\#cccccc", 231 | ${template0}, 232 | "separator": false, 233 | "separator_block_width": 3 234 | }, 235 | # { "full_text": "  ${exec ~/.i3/conky/info.py --get-brightness}"}, 236 | { 237 | "full_text": "  ${exec ~/.i3/conky/info.py --get-keyboard-layout} ", 238 | "border": "\#cccccc", 239 | ${template0}, 240 | "separator": false, 241 | "separator_block_width": 3 242 | }, 243 | { 244 | "full_text": " ${if_empty ${exec cat /sys/class/power_supply/BAT0/status | grep 'Discharging'}} ${else}${endif} ${execi 200 ~/.i3/conky/info.py --battery} ", 245 | # " ${battery_bar 6,60 BAT0}" 246 | "separator": false, 247 | "separator_block_width": 3, 248 | ${template0}, 249 | ${if_empty ${exec cat /sys/class/power_supply/BAT0/status | grep 'Discharging'}} 250 | "border": "\#cccccc" 251 | ${else} 252 | ${if_match ${battery_percent}>=80} 253 | "border": "\#00FF00" # green 254 | ${endif} 255 | ${if_match ${battery_percent}<80} 256 | ${if_match ${battery_percent}>=50} 257 | "border": "\#ffff99" # yellow 258 | ${endif} 259 | ${endif} 260 | ${if_match ${battery_percent}<50} 261 | ${if_match ${battery_percent}>=20} 262 | "border": "\#ff9933" # orange 263 | ${endif} 264 | ${endif} 265 | ${if_match ${battery_percent}<20} 266 | "color": "\#ff0000", # red 267 | "border": "\#ff0000" # red 268 | ${endif} 269 | ${endif} 270 | }, 271 | # ${if_match ${exec /usr/lib/update-notifier/update-motd-updates-available | grep 'security' | awk '{print $1}'}>0} 272 | # { 273 | # "full_text": "⚠ ${exec /usr/lib/update-notifier/update-motd-updates-available | grep 'security' | awk '{print $1}'} security updates", 274 | # "color": "\#ff0000", # red 275 | # "border": "\#ff0000", # red 276 | # "separator_block_width": 3, 277 | # ${template0} 278 | # }, 279 | { 280 | "full_text": " ${time %a %d/%m/%y} - ${time %H:%M}" 281 | } 282 | # ##{ "full_text": "${execi 300 ~/.i3/conky/weather.sh} " }, 283 | ], 284 | 285 | ]]; 286 | -------------------------------------------------------------------------------- /conky/convert.lua: -------------------------------------------------------------------------------- 1 | #! /usr/bin/lua 2 | 3 | local usage = [[ 4 | Usage: convert.lua old_conkyrc [new_conkyrc] 5 | 6 | Tries to convert conkyrc from the old v1.x format to the new, lua-based format. 7 | 8 | Keep in mind that there is no guarantee that the output will work correctly 9 | with conky, or that it will be able to convert every conkyrc. However, it 10 | should provide a good starting point. 11 | 12 | Altough you can use this script with only 1 arg and let it overwrite the old 13 | config, it's suggested to use 2 args so that the new config is written in a new 14 | file (so that you have backup if something went wrong). 15 | 16 | For more information about the new format, read the wiki page 17 | 18 | ]]; 19 | 20 | local function quote(s) 21 | if not s:find("[\n'\\]") then 22 | return "'" .. s .. "'"; 23 | end; 24 | local q = ''; 25 | while s:find(']' .. q .. ']', 1, true) do 26 | q = q .. '='; 27 | end; 28 | return string.format('[%s[\n%s]%s]', q, s, q); 29 | end; 30 | 31 | local bool_setting = { 32 | background = true, disable_auto_reload = true, double_buffer = true, draw_borders = true, 33 | draw_graph_borders = true, draw_outline = true, draw_shades = true, extra_newline = true, 34 | format_human_readable = true, no_buffers = true, out_to_console = true, 35 | out_to_ncurses = true, out_to_stderr = true, out_to_x = true, override_utf8_locale = true, 36 | own_window = true, own_window_argb_visual = true, own_window_transparent = true, 37 | short_units = true, show_graph_range = true, show_graph_scale = true, 38 | times_in_seconds = true, top_cpu_separate = true, uppercase = true, use_xft = true 39 | }; 40 | 41 | local num_setting = { 42 | border_inner_margin = true, border_outer_margin = true, border_width = true, 43 | cpu_avg_samples = true, diskio_avg_samples = true, gap_x = true, gap_y = true, 44 | imlib_cache_flush_interval = true, imlib_cache_size = true, 45 | max_port_monitor_connections = true, max_text_width = true, max_user_text = true, 46 | maximum_width = true, mpd_port = true, music_player_interval = true, net_avg_samples = true, 47 | own_window_argb_value = true, pad_percents = true, stippled_borders = true, 48 | text_buffer_size = true, top_name_width = true, total_run_times = true, 49 | update_interval = true, update_interval_on_battery = true, xftalpha = true, 50 | xinerama_head = true, 51 | }; 52 | 53 | local split_setting = { 54 | default_bar_size = true, default_gauge_size = true, default_graph_size = true, 55 | minimum_size = true 56 | }; 57 | 58 | local colour_setting = { 59 | color0 = true, color1 = true, color2 = true, color3 = true, color4 = true, color5 = true, 60 | color6 = true, color7 = true, color8 = true, color9 = true, default_color = true, 61 | default_outline_color = true, default_shade_color = true, own_window_colour = true 62 | }; 63 | 64 | local function alignment_map(value) 65 | local map = { m = 'middle', t = 'top', b = 'bottom', r = 'right', l = 'left' }; 66 | if map[value] == nil then 67 | return value; 68 | else 69 | return map[value]; 70 | end; 71 | end; 72 | 73 | local function handle(setting, value) 74 | setting = setting:lower(); 75 | if setting == '' then 76 | return ''; 77 | end; 78 | if split_setting[setting] then 79 | local x, y = value:match('^(%S+)%s*(%S*)$'); 80 | local ret = setting:gsub('_size', '_width = ') .. x .. ','; 81 | if y ~= '' then 82 | ret = ret .. ' ' .. setting:gsub('_size', '_height = ') .. y .. ','; 83 | end; 84 | return '\t' .. ret; 85 | end; 86 | if bool_setting[setting] then 87 | value = value:lower(); 88 | if value == 'yes' or value == 'true' or value == '1' or value == '' then 89 | value = 'true'; 90 | else 91 | value = 'false'; 92 | end; 93 | elseif not num_setting[setting] then 94 | if setting == 'alignment' and value:len() == 2 then 95 | value = alignment_map(value:sub(1,1)) .. '_' .. alignment_map(value:sub(2,2)); 96 | elseif colour_setting[setting] and value:match('^[0-9a-fA-F]+$') then 97 | value = '#' .. value; 98 | elseif setting == 'xftfont' then 99 | setting = 'font'; 100 | end; 101 | value = quote(value); 102 | end; 103 | return '\t' .. setting .. ' = ' .. value .. ','; 104 | end; 105 | 106 | local function convert(s) 107 | local setting, comment = s:match('^([^#]*)#?(.*)\n$'); 108 | if comment ~= '' then 109 | comment = '--' .. comment; 110 | end; 111 | comment = comment .. '\n'; 112 | return handle(setting:match('^%s*(%S*)%s*(.-)%s*$')) .. comment; 113 | end; 114 | 115 | local input; 116 | local output; 117 | 118 | if conky == nil then --> standalone program 119 | -- 1 arg: arg is input and outputfile 120 | -- 2 args: 1st is inputfile, 2nd is outputfile 121 | -- 0, 3 or more args: print usage to STDERR and quit 122 | if #arg == 1 or #arg == 2 then 123 | input = io.input(arg[1]); 124 | else 125 | io.stderr:write(usage); 126 | return; 127 | end; 128 | else 129 | -- we are called from conky, the filename is the first argument 130 | input = io.open(..., 'r'); 131 | end; 132 | 133 | 134 | local config = input:read('*a'); 135 | input:close(); 136 | 137 | local settings, text = config:match('^(.-)TEXT\n(.*)$'); 138 | 139 | local converted = 'conky.config = {\n' .. settings:gsub('.-\n', convert) .. '};\n\nconky.text = ' .. 140 | quote(text) .. ';\n'; 141 | 142 | if conky == nil then 143 | if #arg == 2 then 144 | output = io.output(arg[2]); 145 | else 146 | output = io.output(arg[1]); 147 | end 148 | output:write(converted); 149 | output:close(); 150 | else 151 | return assert(loadstring(converted, 'converted config')); 152 | end; 153 | -------------------------------------------------------------------------------- /conky/info.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import subprocess 4 | import sys 5 | #import NetworkManager as nm 6 | import argparse 7 | 8 | 9 | # def get_ip_address(ifname): 10 | # for dev in nm.NetworkManager.GetDevices(): 11 | # if dev.Interface == ifname: 12 | # if dev.State == 20: 13 | # return '' 14 | # elif dev.State == 30: 15 | # return '' 16 | # else: 17 | # return dev.Ip4Address 18 | # return '' 19 | 20 | parser = argparse.ArgumentParser(description='Provides some useful infos about the system.') 21 | 22 | parser.add_argument('--battery', action='store_true', help="show battery infos") 23 | parser.add_argument('--get-brightness', 24 | action='store_true', 25 | dest='get_brightness', 26 | help="show brightness infos") 27 | parser.add_argument('--set-brightness', 28 | action='store', 29 | type=int, 30 | dest='set_brightness', 31 | help="set brightness") 32 | parser.add_argument('--get-keyboard-layout', 33 | action='store_true', 34 | dest='get_keyboard_layout', 35 | help="show keyboard layout infos") 36 | # parser.add_argument('--get-ip', 37 | # action='store', 38 | # dest='get_ip', 39 | # help="get ip for interface") 40 | parser.add_argument('--get-volume', 41 | action='store_true', 42 | dest='get_volume', 43 | help="get source volume") 44 | 45 | args = parser.parse_args() 46 | 47 | if args.battery: 48 | p = subprocess.Popen('acpi -b', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 49 | 50 | for line in p.stdout.readlines(): 51 | name, infos = line.split(': ') 52 | status, percentage, eta = infos.split(', ') 53 | eta = eta[:8] 54 | sys.stdout.write('%s (%s)\n' % (percentage, eta)) 55 | #retval = p.wait() 56 | 57 | elif args.get_brightness: 58 | command_current_b = 'pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness' 59 | command_max_b = 'pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-max-brightness' 60 | 61 | p = subprocess.Popen(command_current_b, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 62 | current_b = int(p.stdout.readlines()[0].replace('\n', '')) 63 | p = subprocess.Popen(command_max_b, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 64 | max_b = int(p.stdout.readlines()[0].replace('\n', '')) 65 | percentage = current_b * 100 / max_b 66 | sys.stdout.write('%s%%\n' % percentage) 67 | elif args.set_brightness: 68 | new_b = int(args.set_brightness) 69 | command = 'pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness %s' 70 | p = subprocess.Popen(command % new_b, shell=True, 71 | stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 72 | # elif args.get_ip: 73 | # interface = args.get_ip 74 | # sys.stdout.write(get_ip_address(interface)) 75 | elif args.get_keyboard_layout: 76 | command = 'setxkbmap -print | grep xkb_symbols | awk \'{print $4}\' | awk -F"+" \'{print $2}\'' 77 | p = subprocess.Popen(command, shell=True, 78 | stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 79 | sys.stdout.write(p.stdout.readlines()[0]) 80 | elif args.get_volume: 81 | import alsaaudio 82 | m = alsaaudio.Mixer(control='IEC958', id=0) # defined alsaaudio.Mixer to change volume 83 | sys.stdout.write(m.getvolume()) 84 | else: 85 | parser.print_help() 86 | -------------------------------------------------------------------------------- /conky/volumelevel.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import alsaaudio 4 | m = alsaaudio.Mixer() # defined alsaaudio.Mixer to change volume 5 | vol = m.getvolume() 6 | print vol 7 | ##!/bin/bash 8 | #vol=`amixer get Master | awk -F'[]%[]' '/%/ {if ($7 == "off") { print "Mute" } else { print $2"%" }}' | uniq | head -1` 9 | #echo "$vol" 10 | -------------------------------------------------------------------------------- /conky/volumelevel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 2 )) | tail -n 1| sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' 3 | -------------------------------------------------------------------------------- /conky/weather.sh: -------------------------------------------------------------------------------- 1 | # User configurables below: 2 | # Uncomment this line for fahrenheit: 3 | #metric='imperial' && unit='F' 4 | # Otherwise comment above line, uncomment here for celcius: 5 | metric='metric' && unit='C' 6 | 7 | # First, geolocate our IP: 8 | ipinfo=$(curl -s ipinfo.io) 9 | latlong=$(echo $ipinfo | jq -r '.loc') 10 | # Parse the latitude and longitude into their own values 11 | lat=44.83 12 | long=11.61 13 | 14 | weather=$(curl -s http://api.openweathermap.org/data/2.5/weather\?lat\=${lat}\&lon\=${long}\&units\=${metric}) 15 | city=$(echo $weather | jq -r '.name') 16 | temperature=$(printf '%.0f' $(echo $weather | jq '.main.temp')) 17 | condition=$(echo $weather | jq -r '.weather[0].main') 18 | 19 | echo -n "$city - $condition: " 20 | echo $temperature °$unit 21 | -------------------------------------------------------------------------------- /i3blocks.conf: -------------------------------------------------------------------------------- 1 | #[clickme] 2 | #full_text=Click me! 3 | #command=echo button=$BLOCK_BUTTON x=$BLOCK_X y=$BLOCK_Y 4 | #min_width=button=1 x=1366 y=768 5 | #align=left 6 | 7 | [eth0] 8 | label=🖧 9 | command=echo "`ip -o -4 addr list eth0 | awk '{print $4}'| cut -d/ -f1`" 10 | interval=30 11 | 12 | [fs_root] 13 | command=df -h --output=pcent / | tail -n 1 14 | label= / 15 | interval=30 16 | 17 | [fs_home] 18 | command=df -h --output=pcent /home | tail -n 1 19 | label= /home 20 | interval=30 21 | 22 | [memory] 23 | command=free | grep Mem | awk '{print int(($3-$7)/$2 * 100),"%";}' 24 | label= 25 | interval=5 26 | 27 | [temp] 28 | command=/usr/share/i3blocks/temperature 29 | label= 30 | interval=5 31 | 32 | [uptime] 33 | command=awk '{printf("%2dh %02dm",($1/60/60%24),($1/60%60))}' /proc/uptime 34 | label= 35 | interval=30 36 | 37 | [volume] 38 | command=echo "`~/.i3/conky/volumelevel.sh`%" 39 | label=♪ 40 | interval=2 41 | 42 | [battery] 43 | command=/usr/share/i3blocks/battery 44 | label= 45 | interval=30 46 | 47 | [time] 48 | command=date '+%a %d/%m/%Y - %H:%M' 49 | label= 50 | interval=5 51 | -------------------------------------------------------------------------------- /i3exit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | lock() { 3 | i3lock -n -ti /home/jack/Pictures/wallpaper.png 4 | } 5 | 6 | case "$1" in 7 | lock) 8 | lock 9 | ;; 10 | logout) 11 | i3-msg exit 12 | ;; 13 | suspend) 14 | gksu pm-suspend 15 | ;; 16 | hibernate) 17 | lock && dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Hibernate 18 | /sbin/reboot 19 | ;; 20 | reboot) 21 | dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart 22 | ;; 23 | shutdown) 24 | #dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop 25 | /sbin/poweroff 26 | ;; 27 | *) 28 | echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}" 29 | exit 2 30 | esac 31 | 32 | exit 0 33 | -------------------------------------------------------------------------------- /i3status.conf: -------------------------------------------------------------------------------- 1 | # i3status configuration file. 2 | # see "man i3status" for documentation. 3 | 4 | # It is important that this file is edited as UTF-8. 5 | # The following line should contain a sharp s: 6 | # ß 7 | # If the above line is not correctly displayed, fix your editor first! 8 | 9 | general { 10 | colors = true 11 | interval = 5 12 | } 13 | 14 | order += "tztime local" 15 | order += "volume master" 16 | #order += "ipv6" 17 | order += "disk /" 18 | order += "disk /home" 19 | #order += "run_watch DHCP" 20 | order += "run_watch VPN" 21 | order += "wireless wlan0" 22 | order += "ethernet eth0" 23 | order += "battery 0" 24 | #order += "load" 25 | 26 | wireless wlan0 { 27 | format_up = "W: (%quality at %essid) %ip" 28 | format_down = "W: down" 29 | } 30 | 31 | ethernet eth0 { 32 | # if you use %speed, i3status requires root privileges 33 | format_up = "E: %ip (%speed)" 34 | format_down = "E: down" 35 | } 36 | 37 | battery 0 { 38 | format = "%status %percentage %remaining" 39 | } 40 | 41 | run_watch DHCP { 42 | pidfile = "/var/run/dhclient*.pid" 43 | } 44 | 45 | run_watch VPN { 46 | pidfile = "/var/run/vpnc/pid" 47 | } 48 | 49 | tztime local { 50 | format = "%H:%M %d/%m/%Y %Z" 51 | } 52 | 53 | load { 54 | format = "%1min" 55 | } 56 | 57 | disk "/" { 58 | format = "/: %free" 59 | } 60 | disk "/home" { 61 | format = "/home: %free" 62 | } 63 | 64 | volume master { 65 | format = "♪: %volume" 66 | device = "default" 67 | mixer = "Master" 68 | mixer_idx = 0 69 | } 70 | --------------------------------------------------------------------------------