From 3a64720df4de3fd564a7a9444864a29693016901 Mon Sep 17 00:00:00 2001 From: Simonas Narbutas Date: Thu, 2 Aug 2018 15:58:24 +0200 Subject: [PATCH] monitors, brightness, battery widget --- .bin/brightness | 7 +++- .bin/multimonitor | 2 ++ .../.config/awesome/rc.lua##Linux.epiphanius | 33 ++++++++++++++++--- .yadm/alt/.zshrc##Linux | 8 ++--- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/.bin/brightness b/.bin/brightness index 23e810c..5651833 100755 --- a/.bin/brightness +++ b/.bin/brightness @@ -12,4 +12,9 @@ function usage_and_exit { if [ ${#} -ne 1 ]; then usage_and_exit fi -xbacklight -inc ${1} +BRIGHTNESS=$(( $( 0 )) +then + echo $BRIGHTNESS > "/sys/class/backlight/intel_backlight/brightness" +fi +echo $(( 100*$BRIGHTNESS/7500 )) diff --git a/.bin/multimonitor b/.bin/multimonitor index 8b51a5d..c2249ce 100755 --- a/.bin/multimonitor +++ b/.bin/multimonitor @@ -7,6 +7,8 @@ then xrandr --output DP1-1 --mode 2560x1440 --pos 1920x0 --rotate normal elif [ "$DISPLAY_COUNT" == 1 ] then + xrandr --output DP1-2 --off + xrandr --output DP1-1 --off xrandr --output eDP1 --primary --mode 1920x1080 --pos 0x0 --rotate normal elif [ "$DISPLAY_COUNT" == 2 ] then diff --git a/.yadm/alt/.config/awesome/rc.lua##Linux.epiphanius b/.yadm/alt/.config/awesome/rc.lua##Linux.epiphanius index 054b729..02634ba 100644 --- a/.yadm/alt/.config/awesome/rc.lua##Linux.epiphanius +++ b/.yadm/alt/.config/awesome/rc.lua##Linux.epiphanius @@ -10,6 +10,9 @@ local beautiful = require("beautiful") local naughty = require("naughty") local menubar = require("menubar") local hotkeys_popup = require("awful.hotkeys_popup").widget +-- Battery notif +local battery = require("battery") + -- Enable hotkeys help widget for VIM and other apps -- when client with a matching name is opened: require("awful.hotkeys_popup.keys") @@ -57,10 +60,10 @@ modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. awful.layout.layouts = { - awful.layout.suit.fair, - awful.layout.suit.fair.horizontal, awful.layout.suit.tile, awful.layout.suit.tile.left, + awful.layout.suit.fair, + awful.layout.suit.fair.horizontal, awful.layout.suit.tile.bottom, awful.layout.suit.tile.top, awful.layout.suit.spiral, @@ -116,6 +119,8 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ -- Keyboard map indicator and switcher mykeyboardlayout = awful.widget.keyboardlayout() +-- Battery +batterywidget = wibox.widget.textbox() -- {{{ Wibar -- Create a textclock widget mytextclock = wibox.widget.textclock() @@ -125,7 +130,7 @@ local cal_notification mytextclock:connect_signal("button::release", function() if cal_notification == nil then - awful.spawn.easy_async([[zsh -c "cal -3 -m --color=always |sed 's#\x1B\[7m\([0-9]\+\)\x1B\[27m#\1#'"]], + awful.spawn.easy_async([[zsh -c "cal -3 -m --color=always |sed 's#\x1B\[7m\([ 0-9]\+\)\x1B\[27m#\1#'"]], function(stdout, stderr, reason, exit_code) cal_notification = naughty.notify{ text = stdout, @@ -257,6 +262,7 @@ awful.screen.connect_for_each_screen(function(s) mykeyboardlayout, wibox.widget.systray(), mytextclock, + batterywidget, s.mylayoutbox, }, } @@ -343,8 +349,18 @@ globalkeys = gears.table.join( {description = "select previous", group = "layout"}), -- Display Brightness - awful.key({}, "XF86MonBrightnessUp", function () awful.util.spawn("/home/snarbutas/.bin/brightness +15", false) end), - awful.key({}, "XF86MonBrightnessDown",function () awful.util.spawn("/home/snarbutas/.bin/brightness -15", false) end), + awful.key({}, "XF86MonBrightnessUp", + function () + awful.spawn.easy_async("/home/snarbutas/.bin/brightness +750", function(stdout, stderr, reason, exit_code) + naughty.notify {title = "💡", text = stdout, timeout = 0.5} + end) + end), + awful.key({}, "XF86MonBrightnessDown", + function () + awful.spawn.easy_async("/home/snarbutas/.bin/brightness -750", function(stdout, stderr, reason, exit_code) + naughty.notify {title = "💡", text = stdout, timeout = 0.5} + end) + end), -- Extend monitor awful.key({ "Control", "Mod4" }, "e", function () awful.util.spawn("/home/snarbutas/.bin/multimonitor", false) end), -- Lock computer @@ -656,4 +672,11 @@ end) client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) + +-- Automatically check battery +batterywidget_timer = timer({timeout = 1}) +batterywidget_timer:connect_signal("timeout", function() + batterywidget:set_text(batteryInfo("BAT0")) +end) +batterywidget_timer:start() -- }}} diff --git a/.yadm/alt/.zshrc##Linux b/.yadm/alt/.zshrc##Linux index a18423c..7d662f1 100644 --- a/.yadm/alt/.zshrc##Linux +++ b/.yadm/alt/.zshrc##Linux @@ -3,10 +3,10 @@ source "/home/snarbutas/.zsh-git-prompt/zshrc.sh" ZSH_THEME_GIT_PROMPT_BRANCH="%{\x1b[3m%}%{$fg[cyan]%}" ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[green]%}%{¤%G%}" ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[blue]%}%{x%G%}" -ZSH_THEME_GIT_PROMPT_CHANGED="%{%F{196}%}%{+%G%}%F{reset}" -ZSH_THEME_GIT_PROMPT_BEHIND="%{%F{196}%}%{↓%F{reset}%G%}" +ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[red]%}%{+%G%}" +ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[red]%}%{↓%G%}" ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[blue]%}%{↑%G%}" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%F{196}%}%{…%F{reset}%G%}" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}%{…%G%}" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}%{✔%G%}" ### =============== Git prompt ================ ### @@ -36,7 +36,7 @@ ttyctl -f stty -ixon -ixoff ## Set a nice prompt -PROMPT='%F{red}[%F{blue}%*%F{red}]%f %F{yellow}bosman%f %F{magenta}[%f%B%F{magenta}%1~%f%b%F{magenta}]%f %(!.%F{196}.%F{46})≫ %f%(!..$(git_super_status)) ' +PROMPT='%F{red}[%F{blue}%*%F{red}]%f %F{yellow}bosman%f %F{magenta}[%f%B%F{magenta}%1~%f%b%F{magenta}]%f %(!.%F{red}.%F{green})≫ %f$(git_super_status) ' RPROMPT=$'%F{cyan}%*%f' ## Set a nice remote prompt