From 97530d7f6c5eb54f5050ca8a0e27079401f30557 Mon Sep 17 00:00:00 2001 From: natto1784 Date: Tue, 8 Feb 2022 01:47:01 +0530 Subject: [PATCH] xmobar, nvim: change themes to tomorrow-night --- home/config/xmonad/padding-icon.sh | 58 ++++++++++++++++++++++++++++++ home/config/xmonad/xmobar.hs | 50 +++++++++++++++++--------- home/config/xmonad/xmonad.hs | 36 ++++++++++++------- home/stuff/services.nix | 3 +- home/stuff/xsession.nix | 2 ++ modules/nvim/default.nix | 3 +- modules/nvim/init.lua | 16 ++++----- 7 files changed, 129 insertions(+), 39 deletions(-) create mode 100755 home/config/xmonad/padding-icon.sh diff --git a/home/config/xmonad/padding-icon.sh b/home/config/xmonad/padding-icon.sh new file mode 100755 index 0000000..af27e98 --- /dev/null +++ b/home/config/xmonad/padding-icon.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Taken from https://github.com/jaor/xmobar/blob/master/examples/padding-icon.sh + +# Detects the width of running window with name given as first +# argument (xprop name '$1') and creates an XPM icon of that width, +# 1px height, and transparent. Outputs an -tag for use in +# xmobar to display the generated XPM icon. +# +# Run script from xmobar and trayer: +# `Run Com "/where/ever/padding-icon.sh" ["panel"] "trayerpad" 10` +# and use `%trayerpad%` in your template. +# or, if you're using for instance stalonetray: +# `Run Com "/where/ever/padding-icon.sh" ["stalonetray"] "tray" 10` + +# Very heavily based on Jonas Camillus Jeppensen code +# https://github.com/jaor/xmobar/issues/239#issuecomment-233206552 + +# Function to create a transparent Wx1 px XPM icon +create_xpm_icon () { +timestamp=$(date) +pixels=$(for i in `seq $1`; do echo -n "."; done) + +cat << EOF > "$2" +/* XPM * +static char * trayer_pad_xpm[] = { +/* This XPM icon is used for padding in xmobar to */ +/* leave room for trayer-srg. It is dynamically */ +/* updated by by trayer-pad-icon.sh which is run */ +/* by xmobar. */ +/* Created: ${timestamp} */ +/* */ +"$1 1 1 1", +/* Colors (none: transparent) */ +". c none", +/* Pixels */ +"$pixels" +}; +EOF +} + +# panel window name +pname=${1:-panel} + +# Width of the trayer window +width=$(xprop -name $pname | grep 'program specified minimum size' | cut -d ' ' -f 5) + +# Icon file name +iconfile="/tmp/$pname-padding-${width:-0}px.xpm" + +# If the desired icon does not exist create it +if [ ! -f $iconfile ] +then + create_xpm_icon $width $iconfile +fi + +# Output the icon tag for xmobar +echo "" diff --git a/home/config/xmonad/xmobar.hs b/home/config/xmonad/xmobar.hs index bc4d199..8047511 100644 --- a/home/config/xmonad/xmobar.hs +++ b/home/config/xmonad/xmobar.hs @@ -1,28 +1,46 @@ -Config { - position = Static { xpos = 0 , ypos = 0, width = 1805, height = 23 }, - font = "xft:Fira Mono:style=Regular:antialias=true:pixelsize=16,Font Awesome 5 Brands:pixelsize=16,Font Awesome 5 Free:pixelsize=16:style=Solid,Lohit Devanagari:style=Regular:pixelsize=16,Lohit Gurmukhi:style=Regular:pixelsize=16,Noto Sans CJK JP:style=Regular:pixelsize=16,Noto Sans CJK KR:style=Regular:pixelsize=16,Noto Sans CJK SC:style=Regular:pixelsize=16" +import Xmobar + +bg, fg, grey, red, green, yellow, blue, magenta, cyan, white, sep :: String +sep = "║" +bg = "#1d1f21" +fg = "#c5c8c6" +grey = "#969896" +red = "#cc6666" +green = "#b5bd68" +yellow = "#f0c674" +blue = "#81a2be" +magenta = "#b294bb" +cyan = "#8abeb7" +white = "#ecebec" + + +config :: Config +config = defaultConfig { + font = "xft:Fira Mono:style=Regular:antialias=true:pixelsize=16,Font Awesome 5 Brands:pixelsize=16,Font Awesome 5 Free:pixelsize=16:style=Solid,Lohit Devanagari:style=Regular:pixelsize=16,Lohit Gurmukhi:style=Regular:pixelsize=16,Noto Sans CJK JP:style=Regular:pixelsize=16,Noto Sans CJK KR:style=Regular:pixelsize=16,Noto Sans CJK SC:style=Regular:pixelsize=16", additionalFonts = [ "xft:Font Awesome 5 Free:pixelsize=15:style=Solid", - "xft:Font Awesome 5 Brands:pixelsize=15" - ] - bgColor = "#1d2021", - fgColor = "#d5c4a1", + "xft:Font Awesome 5 Brands:pixelsize=15"], + bgColor = bg, + fgColor = fg, lowerOnStart = False, overrideRedirect = False, allDesktops = True, persistent = True, commands = [ - Run MultiCpu ["-t","\xf2db %","-L","20","-H","80","-h","#D3869B","-l","#8EC07C","-n","#EBDBB2"] 10, - Run Memory ["-t","\xf538 %","-H","12288","-L","6144","-h","#D3869B","-l","#8EC07C","-n","#EBDBB2"] 20, - Run BatteryP ["BAT1","BAT0","BAT2"] ["-t", "", "-L", "10", "-H", "80", "-l", "#D3869B", "-h", "#8EC07C", "-n", "#EBDBB2", "--", "-O", "Charging", "-o", "%", "-a", "notify-send -u critical 'Battery running out!'", "-A", "5", "--lows", "\xf243 ", "--mediums", "\xf242 ", "--highs", "\xf240 "] 300, - Run Network "wlp0s20f3" ["-t","\xf1eb /"] 10, - Run Date "\xf073 %a - %b, %_d ║ %H:%M:%S " "date" 100, - Run MPD ["-t", "", "--", "-P", ">> ", "-Z", "|| ", "-S", "Stopped", "-h", "127.0.0.1", "-p", "6600"] 10, - -- Run Com "playerctl" ["--player", "playerctld", "metadata", "--format", "{{status}}: {{title}}"] "" 10, - Run Com "pamixer" ["--get-volume"] "" 600, + Run $ MultiCpu ["-t","<fn=1>\xf2db</fn> <total>%","-L","20","-H","80","-h",magenta,"-l",green,"-n",yellow] 10, + Run $ Memory ["-t","<fn=1>\xf538</fn> <usedratio>%","-H","10240","-L","6144","-h",magenta,"-l",green,"-n",yellow] 20, + Run $ BatteryP ["BAT1","BAT0","BAT2"] ["-t", "<acstatus>", "-L", "10", "-H", "80", "-l", magenta, "-h", green, "-n", yellow, "--", "-O", "Charging", "-o", "<left>%", "-a", "notify-send -u critical 'Battery running out!'", "-A", "5", "--lows", "<fn=1>\xf243</fn> ", "--mediums", "<fn=1>\xf242</fn> ", "--highs", "<fn=1>\xf240</fn> "] 300, + Run $ Network "wlp0s20f3" ["-t","<fn=1>\xf1eb</fn> <fc=" ++ magenta ++"><rx>/<tx></fc>"] 10, + Run $ Date "<fn=1>\xf073</fn> %-d/%-m/%-y/%w" "date" 100000, + Run $ Date "%H:%M:%S" "time" 10, + Run $ MPD ["-t", "<statei><title><fn="++ magenta ++"> \xf001</fn>", "--", "-P", ">> ", "-Z", "|| ", "-S", "Stopped", "-h", "127.0.0.1", "-p", "6600"] 10, + Run $ Com "/home/natto/.xmonad/lib/padding-icon.sh" ["stalonetray"] "tray" 10, + Run $ Com "pamixer" ["--get-volume"] "" 100, Run UnsafeStdinReader ], sepChar = "*", alignSep = "--", - template = "<action=`dmenu_run` button=1><icon=/home/natto/.xmonad/lib/nixos.xpm/></action> *UnsafeStdinReader* | <fn=1></fn> *mpd* -- *multicpu* | *memory* | *wlp0s20f3* | *battery* | <fn=1></fn> <fc=#83a598>*pamixer*%</fc> | <fc=#ebdbb2>*date*</fc>" + template = "<action=`dmenu_run` button=1><icon=/home/natto/.xmonad/lib/nixos.xpm/></action> *UnsafeStdinReader* " ++ sep ++ " <fn=1></fn>*mpd* -- *multicpu* " ++ sep ++ " *memory* " ++ sep ++ " *wlp0s20f3* " ++ sep ++ " *battery* " ++ sep ++ " <fn=1>\xf028</fn> <fc=" ++ green ++ ">*pamixer*%</fc> " ++ sep ++ " *date* - *time* *tray*" } +main :: IO () +main = xmobar config diff --git a/home/config/xmonad/xmonad.hs b/home/config/xmonad/xmonad.hs index a83cf05..41f0970 100644 --- a/home/config/xmonad/xmonad.hs +++ b/home/config/xmonad/xmonad.hs @@ -19,20 +19,30 @@ import XMonad.Actions.CycleWindows import qualified XMonad.StackSet as W import qualified Data.Map as M +--colors +bgColor = "#1d1f21" +fgColor = "#c5c8c6" +activeWinColor = "#f0c674" +inactiveWinColor = "#b294bb" +urgentWinColor = "#cc6666" +miscColor = "#8abeb7" + myBorderWidth = 2 myTerminal = "/usr/bin/env st" myFocusFollowsMouse = True -myNormalBorderColor = "#1d2021" +myNormalBorderColor = bgColor myModMask = mod4Mask -myFocusedBorderColor = "#d5c4a1" +myFocusedBorderColor = fgColor myManageHook = composeAll - [ className =? "Discord" --> doFloat ] + [ className =? "Discord" --> doFloat + , className =? "Anki" --> doFloat + ] tabConfig = defaultTheme { - activeTextColor = "#1d2021", - activeColor = "#d5c4a1", - inactiveTextColor = "#d5c4a1", - inactiveColor = "#1d2021" + activeTextColor = bgColor, + activeColor = fgColor, + inactiveTextColor = fgColor, + inactiveColor = bgColor } myXmobarrc = "~/.xmonad/lib/xmobar.hs" @@ -236,12 +246,12 @@ main = do xmproc <- spawnPipe ("xmobar " ++ myXmobarrc) , workspaces = myWorkspaces , logHook = dynamicLogWithPP xmobarPP { ppOutput = hPutStrLn xmproc - , ppCurrent = xmobarColor "#b8bb26" "" . wrap "+" "" - , ppVisible = xmobarColor "#b8bb26" "" - , ppHidden = xmobarColor "#d3869b" "" - , ppTitle = xmobarColor "#ebdbb2" "" . shorten 60 + , ppCurrent = xmobarColor activeWinColor "" . wrap "(" ")" + , ppVisible = xmobarColor activeWinColor "" + , ppHidden = xmobarColor inactiveWinColor "" + , ppTitle = xmobarColor fgColor "" . shorten 40 , ppLayout = const "" - , ppUrgent = xmobarColor "#fabd2f" "" . wrap "!" "" - , ppSep = "<fc=#83a598> ║ </fc>" + , ppUrgent = xmobarColor urgentWinColor "" . wrap "!" "" + , ppSep = "<fc=" ++ miscColor ++ "> ║ </fc>" } } diff --git a/home/stuff/services.nix b/home/stuff/services.nix index 213a928..e440212 100644 --- a/home/stuff/services.nix +++ b/home/stuff/services.nix @@ -89,7 +89,8 @@ in stalonetray = { enable = true; config = { - geometry = "5x1+1805"; + geometry = "5x1-0+0"; + no_shrink = true; window_type = "dock"; sticky = true; icon_size = 23; diff --git a/home/stuff/xsession.nix b/home/stuff/xsession.nix index 9f2db7c..e14e2b8 100644 --- a/home/stuff/xsession.nix +++ b/home/stuff/xsession.nix @@ -13,9 +13,11 @@ xmonad = { enable = true; enableContribAndExtras = true; + extraPackages = hs: [ hs.xmobar ]; config = ../config/xmonad/xmonad.hs; libFiles = { "xmobar.hs" = ../config/xmonad/xmobar.hs; + "padding-icon.sh" = ../config/xmonad/padding-icon.sh; "nixos.xpm" = ../config/xmonad/nixos.xpm; }; }; diff --git a/modules/nvim/default.nix b/modules/nvim/default.nix index 094e00d..dacd147 100644 --- a/modules/nvim/default.nix +++ b/modules/nvim/default.nix @@ -30,7 +30,8 @@ vim-vsnip nvim-treesitter vim-latex-live-preview - (gruvbox.overrideAttrs (oa: { patches = [ ./gruvbox.patch ]; })) + # (gruvbox.overrideAttrs (oa: { patches = [ ./gruvbox.patch ]; })) + base16-vim ]; }; }; diff --git a/modules/nvim/init.lua b/modules/nvim/init.lua index 4819997..6617818 100644 --- a/modules/nvim/init.lua +++ b/modules/nvim/init.lua @@ -140,12 +140,12 @@ bind('n', "<M-o>", ":NvimTreeToggle<CR>", {noremap=true, silent=true}) bind('n', "<Space>r", ":NvimTreeRefresh<CR>", {noremap=true, silent=true}) bind('n', "<Space>f", ":NvimTreeFindFile<CR>", {noremap=true, silent=true}) ---gruvbox -vim.g.gruvbox_italic=1 -vim.g.gruvbox_contrast_dark="hard" -vim.g.gruvbox_contrast_light="hard" +--theme +--im.g.gruvbox_italic=1 +--vim.g.gruvbox_contrast_dark="hard" +--vim.g.gruvbox_contrast_light="hard" vim.o.background="dark" -comm("colorscheme gruvbox") +comm("colorscheme base16-tomorrow-night") --floaterm vim.g.floaterm_keymap_toggle = '<F1>' @@ -311,9 +311,9 @@ local function mode() return mode_map[m] end -hi("Light", "guibg=#fbf1c7 guifg=#1d2021") -hi("Dark", "guibg=#1d2021 guifg=#fbf1c7") -hi("Gray", "guifg=#fbf1c7 guibg=#665c54") +hi("Light", "guibg=#c5c8c6 guifg=#1d1f21") +hi("Dark", "guibg=#1d1f21 guifg=#c5c8c6") +hi("Gray", "guifg=#1d1f21 guibg=#b294bb") local function git() local branch = io.popen([[git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n']]):read("*a")