Bladeren bron

arma-nova initial

Fabian Peter Hammerle 8 jaren geleden
commit
9cba358c48
3 gewijzigde bestanden met toevoegingen van 114 en 0 verwijderingen
  1. 50 0
      battery-rate
  2. 56 0
      screenrc
  3. 8 0
      setup

+ 50 - 0
battery-rate

@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import pydbus
+import datetime
+from gi.repository import GLib
+
+def main(argv):
+
+    loop = GLib.MainLoop()
+
+    battery = pydbus.SystemBus().get(
+            'org.freedesktop.UPower',
+            '/org/freedesktop/UPower/devices/battery_BAT0',
+            )
+
+    def battery_changed():
+        """ screen backtick does not kill the backtick process whenever the screen terminates. """
+        if os.getppid() == 1:
+            loop.quit()
+        """ 0: Unknown
+            1: Charging
+            2: Discharging
+            3: Empty
+            4: Fully charged
+            5: Pending charge
+            6: Pending discharge
+            """
+        if battery.State == 2:
+            sys.stdout.write('%.1fW %s\n' % (
+                battery.EnergyRate,
+                (datetime.datetime.now() + datetime.timedelta(seconds = battery.TimeToEmpty)).strftime("%H:%M"),
+                ))
+        elif battery.State == 4:
+            sys.stdout.write('full\n')
+        else:
+            sys.stdout.write('%d%% %s\n' % (
+                battery.Percentage,
+                (datetime.datetime.now() + datetime.timedelta(seconds = battery.TimeToFull)).strftime("%H:%M"),
+                ))
+        sys.stdout.flush()
+
+    battery.onChanged = battery_changed
+    battery.onPropertiesChanged = lambda interface, attr, l: battery_changed()
+
+    loop.run()
+
+if __name__ == "__main__":
+    sys.exit(main(sys.argv[1:]))

+ 56 - 0
screenrc

@@ -0,0 +1,56 @@
+# If both the lifespan and the autorefresh parameters are zero,
+# the backtick program is expected to stay in the background and generate output once in a while. 
+# In this case, the command is executed right away and screen stores the last line of output. 
+# If a new line gets printed screen will automatically refresh the hardstatus or the captions.
+# backtick 2 0 0 $HOME/.screen-battery-rate
+backtick 2 0 0 $HOME/.config/screen/battery-rate
+hardstatus alwayslastline
+# H hostname of the system
+hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}]%?[%2`]%?[%{B}%d.%m. %{W}%c%{g}]'
+
+defscrollback 10000
+
+# http://stackoverflow.com/questions/17868652/screen-how-to-turn-on-alternate-screen
+altscreen on
+
+# no welcome message
+startup_message off
+
+# 256 colors
+attrcolor b ".I"
+termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
+defbce on
+
+# mouse tracking allows to switch region focus by clicking
+mousetrack on
+# enable use of the mouse's scrollwheel to scroll through the scrollback buffer
+# http://unix.stackexchange.com/questions/43229/is-there-a-way-to-make-screen-scroll-like-a-normal-terminal
+# http://stackoverflow.com/questions/359109/using-the-scrollwheel-in-gnu-screen
+# termcapinfo xterm* ti@:te@
+# termcapinfo xterm 'hs:ts=\E]2;:fs=07:ds=\E]2;screen07'
+
+# layouts
+layout autosave on
+
+# navigating regions
+bind -k kl focus left
+bind -k kd focus down
+bind -k ku focus up
+bind -k kr focus right
+bind h focus left
+bind j focus down
+bind k focus up
+bind l focus right
+
+# resizing regions
+bind -c resize h eval "resize -h -5" "command -c resize"
+bind -c resize j eval "resize -v +3" "command -c resize"
+bind -c resize k eval "resize -v -3" "command -c resize"
+bind -c resize l eval "resize -h +5" "command -c resize"
+bind -c resize -k kl eval "resize -h -5" "command -c resize"
+bind -c resize -k kd eval "resize -v +3" "command -c resize"
+bind -c resize -k ku eval "resize -v -3" "command -c resize"
+bind -c resize -k kr eval "resize -h +5" "command -c resize"
+bind R eval "command -c resize" "echo resize"
+
+# https://gist.github.com/joaopizani/2718397

+ 8 - 0
setup

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+pip install --user pydbus
+
+script_dir="$( dirname "${BASH_SOURCE[0]}" )"
+
+symlink --relative --override "${script_dir}/screenrc" "$HOME/.screenrc"
+symlink --relative --override "${script_dir}/battery-rate" "$HOME/.screen-battery-rate"