aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2021-11-02 20:15:32 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:45 -0600
commitb08e88ef0c569cd000cae836f3c86801a661f8cb (patch)
tree35513423208a35a7f45048954f005f91fd94885a
parentcf47b5282be2a62da2aba1a88c8f9599a333b961 (diff)
downloadrde-b08e88ef0c569cd000cae836f3c86801a661f8cb.tar.gz
rde-b08e88ef0c569cd000cae836f3c86801a661f8cb.tar.bz2
rde-b08e88ef0c569cd000cae836f3c86801a661f8cb.zip
More XMobar sexiness.
Revamped the install script to make it easier to handle the install process.
-rw-r--r--.gitignore1
-rw-r--r--extras/HOME/.config/compton.conf (renamed from compton.conf)5
-rwxr-xr-xextras/HOME/.local/.local/bin/spotify-control40
-rwxr-xr-xextras/HOME/.local/.local/bin/vim83
-rwxr-xr-xextras/HOME/.local/bin/bluetooth-select.sh14
-rwxr-xr-xextras/HOME/.local/bin/spotify-control40
-rw-r--r--extras/HOME/.xmobarrc71
-rwxr-xr-xextras/HOME/.xmonad/build (renamed from build-script.sh)0
-rwxr-xr-xextras/HOME/.xmonad/startup (renamed from startup)0
-rw-r--r--extras/HOME/.xmonad/wallpaper.jpg (renamed from assets/wallpaper.jpg)bin767997 -> 767997 bytes
-rwxr-xr-xextras/HOME/.xmonad/xmobar-bluetooth18
-rwxr-xr-xextras/HOME/.xmonad/xmobar-logo9
-rwxr-xr-xinstall.sh24
-rw-r--r--src/Internal/Keys.hs6
-rw-r--r--src/Main.hs2
-rw-r--r--xmobar/extras/battery/battery.c44
-rw-r--r--xmobarrc62
17 files changed, 338 insertions, 81 deletions
diff --git a/.gitignore b/.gitignore
index f5570ff..bb6c218 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
.stack-work/*
*.cabal
*.lock
+build/*
diff --git a/compton.conf b/extras/HOME/.config/compton.conf
index 90be41d..2728ce1 100644
--- a/compton.conf
+++ b/extras/HOME/.config/compton.conf
@@ -33,7 +33,7 @@ shadow-exclude = [
];
shadow-ignore-shaped = false;
-blur-background = true;
+blur-background = false;
wintypes:
{
@@ -44,9 +44,6 @@ wintypes:
opacity = 0.85;
focus = true;
}
-
-
-
}
# shadow-exclude-reg = "x10+0+0";
# xinerama-shadow-crop = true;
diff --git a/extras/HOME/.local/.local/bin/spotify-control b/extras/HOME/.local/.local/bin/spotify-control
new file mode 100755
index 0000000..751f562
--- /dev/null
+++ b/extras/HOME/.local/.local/bin/spotify-control
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+if [ $# -lt 1 ]
+then
+ echo "No command?"
+ exit
+fi
+
+if [ "$(pidof spotify)" = "" ]
+then
+ echo "Spotify is not running"
+ exit
+fi
+
+case $1 in
+ "play")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
+ ;;
+ "next")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
+ ;;
+ "prev")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
+ ;;
+ "getTitle")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$
+ ;;
+ "getArtist")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$
+ ;;
+ "getAlbum")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "album"|egrep -v "album"|egrep -v "array"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$
+ ;;
+ "getStatus")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|grep 'string "[^"]*"'|sed 's/.*"\(.*\)"[^"]*$/\1/'
+ ;;
+ *)
+ echo "Unknown command: " $1
+ ;;
+esac
diff --git a/extras/HOME/.local/.local/bin/vim b/extras/HOME/.local/.local/bin/vim
new file mode 100755
index 0000000..d0aafa5
--- /dev/null
+++ b/extras/HOME/.local/.local/bin/vim
@@ -0,0 +1,83 @@
+#!/usr/bin/python3
+
+import neovim, os, re, sys, time
+
+# Get a list of buffers that haven't been deleted. `nvim.buffers` includes
+# buffers that have had `:bdelete` called on them and aren't in the buffer
+# list, so we have to filter those out.
+def get_listed_buffers(nvim):
+ return set(buf.number for buf in nvim.buffers \
+ if nvim.eval('buflisted(%d)' % buf.number))
+
+
+def resolve_google3(fname):
+ if fname.startswith('//depot/google3'):
+ cwd = os.getcwd()
+ if "/google3" in cwd:
+ depot_dir = cwd[:cwd.find('/google3')]
+ realfname = fname.replace('//depot', depot_dir)
+ return realfname
+ return fname
+
+# For now, treat all arguments that don't start with - or + as filenames. This
+# is good enough to recognize '-f' and `+11`, which is all this script really
+# needs right now.
+filenames = [
+ re.sub(' ', '\ ', os.path.abspath(resolve_google3(arg)))
+ for arg in sys.argv[1:] if not arg[0] in ['-', '+']
+]
+
+try:
+ nvim_socket = os.environ["NVIM_LISTEN_ADDRESS"]
+except KeyError:
+ # If we aren't running inside a `:terminal`, just exec nvim.
+ os.execvp(u'nvim', sys.argv)
+
+nvim = neovim.attach('socket', path=nvim_socket)
+
+existing_buffers = get_listed_buffers(nvim)
+
+nvim.command('split')
+nvim.command('args %s' % ' '.join(filenames))
+
+new_buffers = get_listed_buffers(nvim).difference(existing_buffers)
+
+for arg in sys.argv:
+ if arg[0] == '+':
+ nvim.command(arg[1:])
+
+# The '-f' flag is a signal that we're in a situation like a `git commit`
+# invocation where we need to block until the user is done with the file(s).
+if '-f' in sys.argv and len(new_buffers) > 0:
+ # The rule here is that the user is 'done' with the opened files when none
+ # of them are visible onscreen. This allows for use cases like hitting `:q`
+ # on a `git commit` tempfile. However, we can't just poll to see if they're
+ # visible, because using `nvim.windows`, `nvim.eval()`, or `nvim.call()`
+ # will interrupt any multi-key mappings the user may be inputting. The
+ # solution is to set a buffer-local autocmd on each opened buffer so that
+ # we only check for visibility immediately after the user either closes or
+ # hides one of the buffers.
+ channel_id = nvim.channel_id
+ for buffer in new_buffers:
+ nvim.command((
+ 'autocmd BufDelete,BufHidden <buffer=%d> ' +
+ 'call rpcnotify(%d, "check_buffers")'
+ ) % (buffer, channel_id))
+
+ stay_open = True
+ while stay_open:
+ nvim.next_message() # block until `rpcnotify` is called
+ open_buffers = [window.buffer.number for window in nvim.windows]
+ stay_open = any([buffer in open_buffers for buffer in new_buffers])
+
+ # Now that none of the opened files are visible anymore, we do a few
+ # cleanup steps before ending the script:
+ # * Clear the arg list, since otherwise `:next` would reopen the tempfile
+ # or whatever.
+ # * Clear the autocmds we added, since `bdelete` just hides the buffer and
+ # the autocmds will still be active if the user reopens the file(s).
+ # * Delete each of the buffers we created.
+ nvim.command('argdel *')
+ for buffer in new_buffers:
+ nvim.command('autocmd! BufDelete,BufHidden <buffer=%d>' % buffer)
+ nvim.command('bdelete! %d' % buffer)
diff --git a/extras/HOME/.local/bin/bluetooth-select.sh b/extras/HOME/.local/bin/bluetooth-select.sh
new file mode 100755
index 0000000..a0b8559
--- /dev/null
+++ b/extras/HOME/.local/bin/bluetooth-select.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+devices="$(bluetoothctl -- devices | sed 's#^Device ##')"
+selection="$(
+ echo -e "$devices\nDisconnect" |
+ dmenu -i -nf "#8888ff" -sb "#8888ff" -p "Connect Bluetooth" -l 12)"
+
+macaddr="${selection%% *}"
+
+if [[ "$macaddr" == "Disconnect" ]] ; then
+ exec bluetoothctl -- disconnect
+fi
+
+exec bluetoothctl -- connect "$macaddr"
diff --git a/extras/HOME/.local/bin/spotify-control b/extras/HOME/.local/bin/spotify-control
new file mode 100755
index 0000000..751f562
--- /dev/null
+++ b/extras/HOME/.local/bin/spotify-control
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+if [ $# -lt 1 ]
+then
+ echo "No command?"
+ exit
+fi
+
+if [ "$(pidof spotify)" = "" ]
+then
+ echo "Spotify is not running"
+ exit
+fi
+
+case $1 in
+ "play")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
+ ;;
+ "next")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
+ ;;
+ "prev")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
+ ;;
+ "getTitle")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$
+ ;;
+ "getArtist")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$
+ ;;
+ "getAlbum")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "album"|egrep -v "album"|egrep -v "array"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$
+ ;;
+ "getStatus")
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|grep 'string "[^"]*"'|sed 's/.*"\(.*\)"[^"]*$/\1/'
+ ;;
+ *)
+ echo "Unknown command: " $1
+ ;;
+esac
diff --git a/extras/HOME/.xmobarrc b/extras/HOME/.xmobarrc
new file mode 100644
index 0000000..ecf53ed
--- /dev/null
+++ b/extras/HOME/.xmobarrc
@@ -0,0 +1,71 @@
+Config
+ { font = "xft:Monofur Nerd Font:size=15"
+ , additionalFonts = [
+ "xft:Monofur bold Nerd Font:style=bold:size=12",
+ "xft:Monofur Nerd Font:size=9",
+ "xft:Monofur bold Nerd Font:size=9",
+ "xft:Monofur Nerd Font:size=6",
+ "xft:Monofur bold Nerd Font:size=40",
+ "xft:Monofur Nerd Font:style=bold:size=12"
+ ]
+ , borderColor = "black"
+ , border = FullBM -1
+ , borderWidth = 2
+ , bgColor = "#17171b"
+ , fgColor = "white"
+ , alpha = 250 -- default: 255
+ , position = TopSize L 100 40
+ , textOffset = -1 -- default: -1
+ , iconOffset = -1 -- default: -1
+ , lowerOnStart = True
+ , pickBroadest = False -- default: False
+ , persistent = True
+ , hideOnStart = False
+ , iconRoot = "/usr/local/google/home/rahm/.xmonad/resources" -- default: "."
+ , allDesktops = True -- default: True
+ , overrideRedirect = False -- default: True
+ , sepChar = "%"
+ , alignSep = "}{"
+ , template =
+ " %logo% <fc=#a0a0a0><fn=3>%uname%</fn></fc><fc=#404040> │\
+ \</fc><fc=#a0a0a0> %date%</fc><fc=#404040> │ \
+ \</fc>%StdinReader%}<fn=1><fc=#8888ff>%time%</fc></fn>\
+ \{ %cpu% <fc=#404040>\
+ \│</fc> %KLMO% <fc=#404040>│\
+ \</fc> <fc=#a0a0a0>%mpris2%</fc> <fc=#404040>│ \
+ \</fc>%bluetooth%%bat% "
+ , commands = [
+ Run StdinReader,
+ Run Memory ["-t", "<usedbar>"] 10,
+ Run Date "%H:%M:%S" "time" 10,
+ Run Date "<fn=3>%m/%d</fn>" "date" 10,
+ Run Cpu [
+ "-t", "<fn=3><fc=#000000><bar></fc></fn>",
+ "-L", "3",
+ "-H", "50",
+ "-b", "─",
+ "-f", "─",
+ "--normal", "green",
+ "--high", "red"
+ ] 10,
+ Run WeatherX "KLMO"
+ [ ("clear", "<fc=#ddcf04>")
+ , ("sunny", "<fc=#ddcf04>")
+ , ("mostly clear", "<fc=#ddcf04>")
+ , ("mostly sunny", "<fc=#ddcf04>")
+ , ("partly sunny", "<fc=#ddcf04>")
+ , ("fair", "<fc=#a0a0a0>🌑")
+ , ("cloudy","<fc=#a0a0a0>摒")
+ , ("overcast","<fc=#808080>")
+ , ("partly cloudy", "<fc=#a0a0a0>杖")
+ , ("mostly cloudy", "<fc=#808080>")
+ , ("considerable cloudiness", "<fc=#a0a0a0>ﭽ")]
+ ["--template", "<skyConditionS></fc><fn=3><fc=#a0a0a0> \
+ \<tempF>°F</fc></fn>"] 360000,
+ Run Mpris2 "spotify" ["-t", "<fc=#1aa54b></fc> <fn=3><title></fn>"] 20,
+ Run Com ".xmonad/xmobar-logo" [] "logo" 0,
+ Run Com "uname" ["-r"] "uname" 0,
+ Run Com ".xmonad/xmobar-bluetooth" [] "bluetooth" 50,
+ Run Com ".xmonad/xmobar-battery" [] "bat" 20
+ ]
+ }
diff --git a/build-script.sh b/extras/HOME/.xmonad/build
index 72b6310..72b6310 100755
--- a/build-script.sh
+++ b/extras/HOME/.xmonad/build
diff --git a/startup b/extras/HOME/.xmonad/startup
index dc302b7..dc302b7 100755
--- a/startup
+++ b/extras/HOME/.xmonad/startup
diff --git a/assets/wallpaper.jpg b/extras/HOME/.xmonad/wallpaper.jpg
index 4976715..4976715 100644
--- a/assets/wallpaper.jpg
+++ b/extras/HOME/.xmonad/wallpaper.jpg
Binary files differ
diff --git a/extras/HOME/.xmonad/xmobar-bluetooth b/extras/HOME/.xmonad/xmobar-bluetooth
new file mode 100755
index 0000000..93caa50
--- /dev/null
+++ b/extras/HOME/.xmonad/xmobar-bluetooth
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+cur=""
+
+bluetoothctl -- info | while read line ; do
+ key=${line%%: *}
+ value=${line//*: }
+
+ if [ "$key" == "Name" ] ; then
+ cur="$value"
+ fi
+
+ if [ "$key" == "Connected" -a "$value" == "yes" ] ; then
+ exec echo "<fc=#4287f5></fc> <fc=#a0a0a0><fn=3>$cur</fn></fc> <fc=#404040>│</fc> "
+ fi
+done
+
+exec echo "<fc=#a0a0a0></fc> <fc=#404040>│</fc>"
diff --git a/extras/HOME/.xmonad/xmobar-logo b/extras/HOME/.xmonad/xmobar-logo
new file mode 100755
index 0000000..848ebd2
--- /dev/null
+++ b/extras/HOME/.xmonad/xmobar-logo
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+case "$(uname -a)" in
+ *-arch-*) exec echo '<fn=5><fc=#1785bd></fc></fn>' ;;
+ *Debian*) exec echo '<fn=5><fc=#c00649></fc></fn>' ;;
+ *Ubuntu*) exec echo '<fn=5><fc=#ff8888></fc></fn>' ;;
+ *Linux*) exec echo '<fn=5><fc=#ffffff></fc></fn>' ;;
+ *BSD*) exec echo '<fn=5><fc=#ff4444></fc></fn>' ;;
+esac
diff --git a/install.sh b/install.sh
index a965ad8..59a5078 100755
--- a/install.sh
+++ b/install.sh
@@ -4,11 +4,23 @@ real_dir=$(dirname $(readlink -f "$0"))
cd "$real_dir"
mkdir -p "$HOME/.xmonad"
+mkdir -p "$HOME/.config"
-cc -o ~/.xmonad/xmobar-battery xmobar/extras/battery/battery.c -lm
+mkdir -p build/extras/HOME/.xmonad
-ln -sfv "$real_dir/build-script.sh" "$HOME/.xmonad/build"
-ln -sfv "$real_dir/compton.conf" "$HOME/.config/compton.conf"
-ln -sfv "$real_dir/startup" "$HOME/.xmonad/startup"
-ln -sfv "$real_dir/xmobarrc" "$HOME/.xmobarrc"
-ln -sfv "$real_dir/assets/wallpaper.jpg" "$HOME/.xmonad/wallpaper.jpg"
+cc -o \
+ build/extras/HOME/.xmonad/xmobar-battery \
+ xmobar/extras/battery/battery.c \
+ -lm
+
+GLOBIGNORE=".:.."
+shopt -u dotglob
+
+cd "$HOME"
+cp -rsvf \
+ "$real_dir"/extras/HOME/* \
+ "$real_dir"/extras/HOME/.* \
+ "$real_dir"/build/extras/HOME/* \
+ "$real_dir"/build/extras/HOME/.* \
+ .
+cd "$real_dir"
diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs
index c97736f..3dff864 100644
--- a/src/Internal/Keys.hs
+++ b/src/Internal/Keys.hs
@@ -85,7 +85,8 @@ newKeys markContext =
, ((modm .|. mod1Mask, xK_s), (void $ spawn "sudo systemctl suspend && xsecurelock"))
, ((modm .|. shiftMask, xK_c), kill)
, ((modm .|. shiftMask, xK_t), withFocused $ windows . W.sink)
- , ((mod4Mask, xK_Escape), (void $ spawn "xterm"))
+ , ((mod4Mask, xK_BackSpace), (void $ spawn "xterm"))
+ , ((mod3Mask, xK_BackSpace), (void $ spawn "pkill -SIGUSR1 xmobar"))
, ((mod3Mask, xK_t), (void $ spawn (terminal config)))
, ((modm, xK_m), (submap $ mapAlpha modm (markCurrentWindow markContext)))
, ((modm, xK_w), runXPlus markContext config windowJump)
@@ -122,6 +123,9 @@ newKeys markContext =
, ((modm, xK_q), spawn "xmonad --recompile && xmonad --restart")
, ((modm, xK_z), sendMessage ToggleZoom)
+ , ((modm, xK_x), spawn "bluetooth-select.sh")
+ , ((modm .|. shiftMask, xK_x), spawn "bluetoothctl -- disconnect")
+
, ((modm, xK_Tab), windows W.focusDown)
, ((modm .|. shiftMask, xK_Tab), windows W.focusUp)
diff --git a/src/Main.hs b/src/Main.hs
index 195c151..85d18c7 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -58,7 +58,7 @@ main = do
"xmobar"
xmobarPP {
ppCurrent = xmobarColor "#ff8888" "red" . printf "<fn=1>%s</fn>"
- , ppVisible = xmobarColor "#8888ff" "" . printf "<fn=0>%s</fn>"
+ , ppVisible = xmobarColor "#8888ff" "" . printf "<fn=6>%s</fn>"
, ppHidden = xmobarColor "#888888" "" . printf "<fn=2>%s</fn>"
, ppWsSep = "<fn=1><fc=#808080> </fc></fn>"
, ppTitle =
diff --git a/xmobar/extras/battery/battery.c b/xmobar/extras/battery/battery.c
index 8e5e58e..791bc69 100644
--- a/xmobar/extras/battery/battery.c
+++ b/xmobar/extras/battery/battery.c
@@ -13,7 +13,7 @@ char* icons[] = {
"",
"",
"",
- "",
+ "",
"",
"",
"",
@@ -162,14 +162,22 @@ uint32_t percentage_to_color(int percentage)
return hsv_to_rgb(h, s, v);
}
-void get_time_left(char* buf, size_t sz, llong_t energy, llong_t power)
+void get_time_left(
+ char* buf,
+ size_t sz,
+ llong_t energy,
+ llong_t power)
{
+ if (power == 0) {
+ buf[0] = 0;
+ return;
+ }
llong_t minutes_left = energy * 60 / power;
llong_t hours = minutes_left / 60;
llong_t minutes = minutes_left % 60;
- snprintf(buf, sz - 1, "%2lluh%2llum", hours, minutes);
+ snprintf(buf, sz - 1, "%lluh%2llum", hours, minutes);
buf[sz - 1] = 0;
}
@@ -177,9 +185,12 @@ int main(int argc, char** argv)
{
char* icon;
char timeleft[128];
+ char watts[128];
+ char percent[128];
llong_t capacity;
llong_t energy_now;
+ llong_t energy_full;
llong_t ac_online;
llong_t power;
@@ -206,18 +217,37 @@ int main(int argc, char** argv)
ac_online = !! ac_online;
int percentage = (int) capacity;
- if (percentage >= 100) {
+ if (percentage >= 98) {
icon = icons[10 + ac_online];
} else {
int quintile = percentage / 20;
icon = icons[quintile + (5 * ac_online) ];
}
- get_time_left(timeleft, sizeof(timeleft), energy_now, power);
+ if (ac_online) {
+ if ((energy_full = get_energy_full()) < 0) {
+ fprintf(stderr, "Unable to get current energy.");
+ goto fail;
+ }
+ get_time_left(timeleft, sizeof(timeleft), energy_full - energy_now, power);
+ } else {
+ get_time_left(timeleft, sizeof(timeleft), energy_now, power);
+ }
+
+ watts[0] = 0;
+ percent[0] = 0;
+ if (power) {
+ double dpower = power / 1000000.0;
+ snprintf(watts, sizeof(watts), "%2.1fW ", dpower);
+ }
+
+ if (percentage < 99 || ! ac_online) {
+ snprintf(percent, sizeof(percent), "%2d%% ", percentage);
+ }
- double dpower = power / 1000000.0;
uint32_t color = percentage_to_color(percentage);
- printf("<fc=#%06x>%s </fc><fc=#8888ff>%d%% %2.1fW %s</fc>", color, icon, percentage, dpower, timeleft);
+ printf("<fc=#%06x>%s </fc><fn=3><fc=#a0a0a0>%s%s%s</fc></fn>",
+ color, icon, percent, watts, timeleft);
return 0;
fail:
diff --git a/xmobarrc b/xmobarrc
deleted file mode 100644
index 2893a17..0000000
--- a/xmobarrc
+++ /dev/null
@@ -1,62 +0,0 @@
-Config
- { font = "xft:Monofur Nerd Font:size=15"
- , additionalFonts = [
- "xft:Monofur bold Nerd Font:style=bold:size=15",
- "xft:Monofur Nerd Font:size=12",
- "xft:Monofur Nerd Font:size=12" ]
- , borderColor = "black"
- , border = FullB
- , borderWidth = 2
- , bgColor = "#17171b"
- , fgColor = "white"
- , alpha = 250 -- default: 255
- , position = TopSize L 100 50
- , textOffset = -1 -- default: -1
- , iconOffset = -1 -- default: -1
- , lowerOnStart = True
- , pickBroadest = False -- default: False
- , persistent = True
- , hideOnStart = False
- , iconRoot = "/usr/local/google/home/rahm/.xmonad/resources" -- default: "."
- , allDesktops = True -- default: True
- , overrideRedirect = False -- default: True
- , sepChar = "%"
- , alignSep = "}{"
- , template = " <fc=#ff8888></fc> <fc=#404040> │</fc><fc=#ff8888> %date%</fc><fc=#404040> │ </fc>%StdinReader% }<fc=#8888ff>%time%</fc>{ %cpu% <fc=#404040>│</fc> %KBDU% <fc=#404040>│</fc> <fc=#8888ff>%uname%</fc> <fc=#404040>│ </fc>%bat% "
- , commands = [
- Run Battery [ "--template" , "<fn=1><acstatus></fn>"
- , "--Low" , "10" -- units: %
- , "--High" , "80" -- units: %
- , "--low" , "darkred"
- , "--normal" , "darkorange"
- , "--high" , "darkgreen"
-
- , "--" -- battery specific options
- -- discharging status
- , "-o" , " (<left>%, <timeleft>)"
- -- AC "on" status
- , "-O" , "<fc=#dA20A5> (<left>%)</fc>"
- -- charged status
- , "-i" , "<fc=#006000></fc>"
- ] 50,
- Run StdinReader,
- Run Date "%H:%M:%S" "time" 10,
- Run Date "%m/%d" "date" 10,
- Run Cpu ["-t", "<total>%", "-L","3","-H","50","--normal","green","--high","red"] 10,
- Run WeatherX "KBDU"
- [ ("clear", "<fc=#ddcf04>")
- , ("sunny", "<fc=#ddcf04>")
- , ("mostly clear", "<fc=#ddcf04>")
- , ("mostly sunny", "<fc=#ddcf04>")
- , ("partly sunny", "<fc=#ddcf04>")
- , ("fair", "<fc=#a0a0a0>🌑")
- , ("cloudy","<fc=#a0a0a0>摒")
- , ("overcast","<fc=#808080>")
- , ("partly cloudy", "<fc=#a0a0a0>杖")
- , ("mostly cloudy", "<fc=#808080>")
- , ("considerable cloudiness", "<fc=#a0a0a0>ﭽ")]
- ["--template", "<skyConditionS></fc><fc=#8888ff> <tempF>°F</fc>"] 360000,
- Run Com "uname" ["-r"] "uname" 0,
- Run Com ".xmonad/xmobar-battery" [] "bat" 20
- ]
- }