Replace Xmobar with Polybar
- Remove unneeded imports - Move global tangle path to individual code blocks - Add docks hook to avoid polybar when tiling - Add dwm-style workspace cycling - Fix keybindings to put ctrl before shift - Reset window sizes when force re-tiling - Add ewmhDesktopsEventHook to myEventHook for polybar integration - Launch polybar instead of xmobar - No tangle xmobar config and delete it - Add polybar config from dwm with bunch of tweaks
This commit is contained in:
1394
README.org
1394
README.org
File diff suppressed because it is too large
Load Diff
1092
polybar/config.ini
Normal file
1092
polybar/config.ini
Normal file
File diff suppressed because it is too large
Load Diff
37
polybar/launch.sh
Executable file
37
polybar/launch.sh
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BAR="mybar"
|
||||||
|
CONFIG="~/.xmonad/polybar/config.ini"
|
||||||
|
NUM_MONITORS=0
|
||||||
|
CONNECTED_MONITORS=$(xrandr --query | grep " connected" | cut -d" " -f1)
|
||||||
|
TRAY_POS="right"
|
||||||
|
|
||||||
|
killall -q polybar
|
||||||
|
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
||||||
|
|
||||||
|
rm /tmp/polybar.pids
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
for m in $CONNECTED_MONITORS; do
|
||||||
|
let "NUM_MONITORS+=1"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $NUM_MONITORS == 1 ]; then
|
||||||
|
# Launch on only monitor w/ systray
|
||||||
|
MONITOR=$CONNECTED_MONITORS TRAY_POS=$TRAY_POS polybar --reload -c $CONFIG $BAR &
|
||||||
|
else
|
||||||
|
PRIMARY=$(xrandr --query | grep " connected" | grep "primary" | cut -d" " -f1)
|
||||||
|
OTHERS=$(xrandr --query | grep " connected" | grep -v "primary" | cut -d" " -f1)
|
||||||
|
|
||||||
|
# Launch on primary monitor w/ systray
|
||||||
|
MONITOR=$PRIMARY TRAY_POS=$TRAY_POS polybar --reload -c $CONFIG $BAR &
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# Launch on all other monitors w/o systray
|
||||||
|
for m in $OTHERS; do
|
||||||
|
MONITOR=$m TRAY_POS=none polybar --reload -c $CONFIG $BAR &
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$!" >>/tmp/polybar.pids
|
18
polybar/scripts/dunst-notification-status.sh
Executable file
18
polybar/scripts/dunst-notification-status.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if dunst is running
|
||||||
|
if pgrep -x "dunst" > /dev/null
|
||||||
|
then
|
||||||
|
is_paused=$(dunstctl is-paused)
|
||||||
|
|
||||||
|
if [[ $is_paused == 'false' ]]; then
|
||||||
|
status_icon=" on"
|
||||||
|
elif [[ $is_paused == 'true' ]]; then
|
||||||
|
status_icon=" off"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
status_icon=" off"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $status_icon
|
20
polybar/scripts/get-media-playing.sh
Executable file
20
polybar/scripts/get-media-playing.sh
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
|
||||||
|
|
||||||
|
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
|
||||||
|
echo " N/A"
|
||||||
|
else
|
||||||
|
artist=$(playerctl --player=playerctld metadata --format '{{ artist }}')
|
||||||
|
title=$(playerctl --player=playerctld metadata --format '{{ title }}')
|
||||||
|
status=$(playerctl --player=playerctld metadata --format '{{ status }}')
|
||||||
|
|
||||||
|
if [[ $status == "Paused" ]]; then
|
||||||
|
status_icon=" "
|
||||||
|
elif [[ $status == "Playing" ]]; then
|
||||||
|
status_icon=" "
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$status_icon $artist - $title"
|
||||||
|
fi
|
13
polybar/scripts/updates-pacman-aurhelper.sh
Executable file
13
polybar/scripts/updates-pacman-aurhelper.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if ! num_updates=$(paru -Qu 2>/dev/null | wc -l); then
|
||||||
|
# if ! updates_aur=$(yay -Qum 2>/dev/null | wc -l); then
|
||||||
|
# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then
|
||||||
|
# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then
|
||||||
|
# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then
|
||||||
|
# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then
|
||||||
|
num_updates=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$num_updates"
|
@@ -1,31 +0,0 @@
|
|||||||
Config { font = "xft:FiraCode Nerd Font Mono:weight=bold:pixelsize=12:antialias=true:hinting=true"
|
|
||||||
, additionalFonts = []
|
|
||||||
, borderColor = "black"
|
|
||||||
, border = TopB
|
|
||||||
, bgColor = "black"
|
|
||||||
, fgColor = "white"
|
|
||||||
, alpha = 255
|
|
||||||
, position = Top
|
|
||||||
, textOffset = -1
|
|
||||||
, iconOffset = -1
|
|
||||||
, lowerOnStart = True
|
|
||||||
, pickBroadest = False
|
|
||||||
, persistent = False
|
|
||||||
, hideOnStart = False
|
|
||||||
, iconRoot = "."
|
|
||||||
, allDesktops = True
|
|
||||||
, overrideRedirect = True
|
|
||||||
, commands = [ Run Weather "K7D2" ["-t","<station>: <tempF>F","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000
|
|
||||||
, Run Network "wlp0s20f3" ["-L","0","-H","32","--normal","green","--high","red"] 10
|
|
||||||
, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
|
|
||||||
, Run Memory ["-t","Mem: <usedratio>%"] 10
|
|
||||||
, Run Swap [] 10
|
|
||||||
, Run Com "uname" ["-s","-r"] "" 36000
|
|
||||||
, Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
|
|
||||||
, Run StdinReader
|
|
||||||
]
|
|
||||||
, sepChar = "%"
|
|
||||||
, alignSep = "}{"
|
|
||||||
, template = "%StdinReader% }\
|
|
||||||
\{ %cpu% | %memory% * %swap% | %wlp0s20f3% | <fc=#ee9a00>%date%</fc> | %uname%"
|
|
||||||
}
|
|
58
xmonad.hs
58
xmonad.hs
@@ -6,9 +6,6 @@ import System.Exit
|
|||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
-- system
|
|
||||||
import System.IO (hPutStrLn)
|
|
||||||
|
|
||||||
-- util
|
-- util
|
||||||
import XMonad.Util.Run (safeSpawn, unsafeSpawn, runInTerm, spawnPipe)
|
import XMonad.Util.Run (safeSpawn, unsafeSpawn, runInTerm, spawnPipe)
|
||||||
import XMonad.Util.SpawnOnce
|
import XMonad.Util.SpawnOnce
|
||||||
@@ -16,13 +13,14 @@ import XMonad.Util.EZConfig (additionalKeysP, additionalMouseBindings)
|
|||||||
|
|
||||||
-- hooks
|
-- hooks
|
||||||
import XMonad.Hooks.DynamicLog
|
import XMonad.Hooks.DynamicLog
|
||||||
import XMonad.Hooks.ManageDocks (avoidStruts, docksStartupHook, manageDocks, ToggleStruts(..))
|
import XMonad.Hooks.ManageDocks (docks, avoidStruts, docksStartupHook, manageDocks, ToggleStruts(..))
|
||||||
import XMonad.Hooks.EwmhDesktops
|
import XMonad.Hooks.EwmhDesktops
|
||||||
import XMonad.Hooks.ManageHelpers (isFullscreen, isDialog, doFullFloat, doCenterFloat, doRectFloat)
|
import XMonad.Hooks.ManageHelpers (isFullscreen, isDialog, doFullFloat, doCenterFloat, doRectFloat)
|
||||||
import XMonad.Hooks.Place (placeHook, withGaps, smart)
|
import XMonad.Hooks.Place (placeHook, withGaps, smart)
|
||||||
|
|
||||||
-- actions
|
-- actions
|
||||||
import XMonad.Actions.CopyWindow
|
import XMonad.Actions.CopyWindow
|
||||||
|
import XMonad.Actions.CycleWS
|
||||||
|
|
||||||
-- layout
|
-- layout
|
||||||
import XMonad.Layout.NoBorders
|
import XMonad.Layout.NoBorders
|
||||||
@@ -57,8 +55,8 @@ myKeys =
|
|||||||
++
|
++
|
||||||
[
|
[
|
||||||
-- dwm-like add/remove window to/from all workspaces
|
-- dwm-like add/remove window to/from all workspaces
|
||||||
("M-S-C-a", windows copyToAll) -- copy window to all workspaces
|
("M-C-S-a", windows copyToAll) -- copy window to all workspaces
|
||||||
, ("M-S-C-z", killAllOtherCopies) -- kill copies of window on other workspaces
|
, ("M-C-S-z", killAllOtherCopies) -- kill copies of window on other workspaces
|
||||||
|
|
||||||
-- modify tiled window size
|
-- modify tiled window size
|
||||||
, ("M-a", sendMessage MirrorShrink) -- decrease vertical window size
|
, ("M-a", sendMessage MirrorShrink) -- decrease vertical window size
|
||||||
@@ -71,16 +69,27 @@ myKeys =
|
|||||||
, ("M-f", sendMessage $ JumpToLayout "Full")
|
, ("M-f", sendMessage $ JumpToLayout "Full")
|
||||||
, ("M-S-f", sequence_
|
, ("M-S-f", sequence_
|
||||||
[ withFocused $ windows . W.sink
|
[ withFocused $ windows . W.sink
|
||||||
|
, refresh
|
||||||
, sendMessage $ JumpToLayout "Full"])
|
, sendMessage $ JumpToLayout "Full"])
|
||||||
, ("M-t", sendMessage $ JumpToLayout "Spacing ResizableTall")
|
, ("M-t", sendMessage $ JumpToLayout "Spacing ResizableTall")
|
||||||
, ("M-S-t", sequence_
|
, ("M-S-t", sequence_
|
||||||
[ withFocused $ windows . W.sink
|
[ withFocused $ windows . W.sink
|
||||||
|
, refresh
|
||||||
, sendMessage $ JumpToLayout "Spacing ResizableTall"])
|
, sendMessage $ JumpToLayout "Spacing ResizableTall"])
|
||||||
, ("M-g", sendMessage $ JumpToLayout "Spacing Grid")
|
, ("M-g", sendMessage $ JumpToLayout "Spacing Grid")
|
||||||
, ("M-S-g", sequence_
|
, ("M-S-g", sequence_
|
||||||
[ withFocused $ windows . W.sink
|
[ withFocused $ windows . W.sink
|
||||||
|
, refresh
|
||||||
, sendMessage $ JumpToLayout "Spacing Grid"])
|
, sendMessage $ JumpToLayout "Spacing Grid"])
|
||||||
|
|
||||||
|
-- cycle & move between screens
|
||||||
|
, ("M-,", prevScreen)
|
||||||
|
, ("M-S-,", shiftPrevScreen)
|
||||||
|
, ("M-C-S-,", swapPrevScreen)
|
||||||
|
, ("M-.", nextScreen)
|
||||||
|
, ("M-S-.", shiftNextScreen)
|
||||||
|
, ("M-C-S-.", swapNextScreen)
|
||||||
|
|
||||||
-- launch rofi
|
-- launch rofi
|
||||||
, ("M-p", spawn "rofi -show combi")
|
, ("M-p", spawn "rofi -show combi")
|
||||||
, ("M-c", spawn "rofi -show clipboard")
|
, ("M-c", spawn "rofi -show clipboard")
|
||||||
@@ -164,6 +173,8 @@ myManageHook = composeAll
|
|||||||
|
|
||||||
myPlacement = withGaps (16,0,16,0) (smart (0.5,0.5))
|
myPlacement = withGaps (16,0,16,0) (smart (0.5,0.5))
|
||||||
|
|
||||||
|
myEventHook = ewmhDesktopsEventHook
|
||||||
|
|
||||||
myStartupHook = do
|
myStartupHook = do
|
||||||
-- System Restore Processes
|
-- System Restore Processes
|
||||||
spawnOnce "/home/sravan/.screenlayout/default.sh &" -- restore default screen layout
|
spawnOnce "/home/sravan/.screenlayout/default.sh &" -- restore default screen layout
|
||||||
@@ -171,7 +182,6 @@ myStartupHook = do
|
|||||||
spawnOnce "numlockx on &" -- enable numlock
|
spawnOnce "numlockx on &" -- enable numlock
|
||||||
|
|
||||||
-- System Tray Applications
|
-- System Tray Applications
|
||||||
spawnOnce "volctl &" -- PulseAudio Volume Control
|
|
||||||
spawnOnce "nyrna &" -- Nyrna Application Suspend
|
spawnOnce "nyrna &" -- Nyrna Application Suspend
|
||||||
spawnOnce "blueman-applet &" -- Blueman Bluetooth Manager
|
spawnOnce "blueman-applet &" -- Blueman Bluetooth Manager
|
||||||
spawnOnce "nm-applet &" -- Network Manager Applet
|
spawnOnce "nm-applet &" -- Network Manager Applet
|
||||||
@@ -189,10 +199,11 @@ myStartupHook = do
|
|||||||
spawnOnce "light-locker --lock-on-suspend --lock-on-lid &" -- screen lock for lightdm
|
spawnOnce "light-locker --lock-on-suspend --lock-on-lid &" -- screen lock for lightdm
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
-- `xmobar -x 0` launches the bar on monitor 0
|
-- launches polybar
|
||||||
xmproc <- spawnPipe "xmobar -x 0 /home/sravan/.xmonad/xmobar.config"
|
spawn "/home/sravan/.xmonad/polybar/launch.sh &"
|
||||||
-- launches xmobar as a dock
|
|
||||||
xmonad $ ewmh desktopConfig
|
-- launches xmonad
|
||||||
|
xmonad $ docks $ ewmh desktopConfig
|
||||||
{ manageHook = manageDocks <+> myManageHook <+> placeHook myPlacement <+> manageHook desktopConfig
|
{ manageHook = manageDocks <+> myManageHook <+> placeHook myPlacement <+> manageHook desktopConfig
|
||||||
, startupHook = myStartupHook
|
, startupHook = myStartupHook
|
||||||
, layoutHook = myLayout
|
, layoutHook = myLayout
|
||||||
@@ -201,24 +212,15 @@ main = do
|
|||||||
, modMask = myModMask
|
, modMask = myModMask
|
||||||
, normalBorderColor = myNormalBorderColor
|
, normalBorderColor = myNormalBorderColor
|
||||||
, focusedBorderColor = myFocusedBorderColor
|
, focusedBorderColor = myFocusedBorderColor
|
||||||
, logHook = dynamicLogWithPP xmobarPP
|
, handleEventHook = myEventHook
|
||||||
{ ppOutput = \x -> hPutStrLn xmproc x
|
, focusFollowsMouse = myFocusFollowsMouse
|
||||||
, ppCurrent = xmobarColor "green" "" . wrap "[" "]" -- current workspace in xmobar
|
, clickJustFocuses = myClickJustFocuses
|
||||||
, ppVisible = xmobarColor "cyan" "" -- visible but not current workspace
|
, workspaces = myWorkspaces
|
||||||
, ppHidden = xmobarColor "yellow" "" . wrap "+" "" -- hidden workspaces in xmobar
|
, mouseBindings = myMouseBindings
|
||||||
, ppHiddenNoWindows = xmobarColor "white" "" -- hidden workspaces (no windows)
|
-- , logHook = myLogHook
|
||||||
, ppTitle = xmobarColor "purple" "" . shorten 80 -- title of active window in xmobar
|
-- , keys = myKeys
|
||||||
, ppSep = " | " -- separators in xmobar
|
|
||||||
, ppUrgent = xmobarColor "red" "" . wrap "!" "!" -- urgent workspace
|
|
||||||
, ppOrder = \(ws:l:t:ex) -> [ws,l,t]
|
|
||||||
}
|
}
|
||||||
-- focusFollowsMouse = myFocusFollowsMouse,
|
`additionalKeysP` myKeys
|
||||||
-- clickJustFocuses = myClickJustFocuses,
|
|
||||||
-- workspaces = myWorkspaces,
|
|
||||||
-- keys = myKeys,
|
|
||||||
-- mouseBindings = myMouseBindings,
|
|
||||||
-- handleEventHook = myEventHook,
|
|
||||||
} `additionalKeysP` myKeys
|
|
||||||
|
|
||||||
help :: String
|
help :: String
|
||||||
help = unlines ["The default modifier key is 'alt'. Default keybindings:",
|
help = unlines ["The default modifier key is 'alt'. Default keybindings:",
|
||||||
|
Reference in New Issue
Block a user