eww-start

This commit is contained in:
2025-04-30 13:35:31 +02:00
parent 61a35c611a
commit 7fb65ea258
6 changed files with 141 additions and 165 deletions

View File

@@ -1,97 +1,29 @@
(defwindow bar-primary
:monitor 0
:geometry (geometry :x "0px"
:y "25px"
:width "100%"
:height "25px"
:anchor "top center")
:stacking "fg"
:reserve (struts :distance "50px" :side "top")
:windowtype "dock"
:wm-ignore false
(box
:orientation "horizontal"
:halign "right"
(eventbox :onclick "notify-send Left"
:onrightclick "notify-send Right"
"Click Me!")
(rightSideBar)))
(defwidget workspaces-and-windows []
(let content (split " " (file "/tmp/xmonad-eww-log"))
(let ws-list (take 9 content)
(let win-list (drop 9 content)
(box :orientation "vertical" :class "bar"
;; The Wrapper of the rightside Information
(defwidget rightSideBar []
(box
:space-evenly "false"
:halign "end"
(audio)
(nw)
(date)
))
;; Workspaces
(box :orientation "horizontal"
(for ws in ws-list
(let class (if (starts-with ws "[[")
"ws-current"
(if (starts-with ws "(")
"ws-visible"
"ws-hidden")))
(let name (string-trim ws "[]()")
(button :onclick (format "wmctrl -s %s" name)
:class class
(label :text name))))))
;; The Internet Information box.
(defwidget audio []
(box :class "container"
:space-evenly "false"
:halign "end"
(label :class "iconBat" :text "${volicon} ")
(label :class "text" :text "${vol} % ")
(label :class "text" :text "${micicon} ")))
;; The Internet Information box.
(defwidget nw []
(box :class "container"
:space-evenly "false"
:halign "end"
(label :class "iconNWDown" :text " ")
(label :class "text" :text " ${nwdown} ")
(label :class "iconNWUp" :text " ")
(label :class "text" :text "${nwup} ")))
;; The date Information box.
(defwidget date []
(box :class "container"
:space-evenly "false"
:halign "end"
(label :class "iconClock" :text " ")
(label :class "text" :text "${date-time} ")))
;; Variables
(defpoll volicon
:interval "1s"
:initial "-" ; optional, defaults to poll at startup
`if [[ $(cut -d ' ' -f 2 <<< $(pulseaudio-ctl full-status)) == "yes" ]]; then echo "󰝟"; else echo ""; fi`)
(defpoll vol
:interval "1s"
:initial "-" ; optional, defaults to poll at startup
`Volume=$(cut -d ' ' -f 1 <<<$(pulseaudio-ctl full-status)); echo "$(( Volume/2 ))"`)
(defpoll micicon
:interval "1s"
:initial "-" ; optional, defaults to poll at startup
`if [[ $(cut -d ' ' -f 3 <<< $(pulseaudio-ctl full-status)) == "yes" ]]; then echo ""; else echo ""; fi`)
(defpoll nwup ;; TODO
:interval "1s"
:initial "-" ; optional, defaults to poll at startup
`echo "up"`)
(defpoll nwdown ; TODO
:interval "1s"
:initial "-" ; optional, defaults to poll at startup
`echo "down"`)
(defpoll date-time
:interval "1s"
:initial "initial-value" ; optional, defaults to poll at startup
`date "+%a %d.%m.%y %H:%M:%S"`)
;; IDK
(defwidget greeter [?text name]
(box :orientation "horizontal"
:halign "center"
:geometry (geometry :x "0px"
:y "0px"
:height "20px"
:anchor "top center")
text))
;; Open windows
(box :orientation "horizontal" :class "window-list"
(for win in win-list
(let class (if (starts-with win "*") "win-focused" "win")
(label :class class :text (string-trim win "*")))))
)
)
)
)
)

View File

@@ -0,0 +1,4 @@
tail -F /tmp/xmonad-eww-log | while read -r line; do
clean_line=$(echo "$line" | sed -E 's/<[^>]+>//g')
eww update xmonad_log="$clean_line"
done

View File

@@ -5,6 +5,7 @@ return {
name = "catppuccin",
priority = 1000,
config = function()
require("catppuccin").setup()
vim.cmd.colorscheme("catppuccin-mocha")
end,
opts = {

View File

@@ -19,5 +19,7 @@
xorg.xmessage
ghc
cabal-install
wmctrl
trayer
];
}

View File

@@ -1,102 +1,101 @@
import XMonad
import XMonad.Util.SpawnOnce (spawnOnce)
import XMonad.Hooks.EwmhDesktops
import XMonad.Util.EZConfig
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Magnifier
import XMonad.Util.ClickableWorkspaces
import XMonad.Util.Loggers
import Data.ByteString (maximum)
import Distribution.Compat.Prelude (print)
--import Control.Monad.RWS (All(All))
import System.IO
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import XMonad.Layout.Magnifier
import XMonad.Layout.ThreeColumns
import XMonad.Util.ClickableWorkspaces
import XMonad.Util.EZConfig
import XMonad.Util.Loggers
import XMonad.Util.Run (spawnPipe)
import XMonad.Util.SpawnOnce (spawnOnce)
-- import Control.Monad.RWS (All(All))
import XMonad.Hooks.ManageHelpers
main = do
xmonad . ewmhFullscreen . ewmh $ myConfig
main = xmonad . ewmhFullscreen . ewmh . withEasySB (statusBarProp "xmobar" (pure myXmobarPP)) defToggleStrutsKey $ myconfig
myConfig =
def
{ modMask = mod4Mask
, terminal = "alacritty"
, layoutHook = avoidStruts myLayout
, normalBorderColor = "#f5c2e7"
, focusedBorderColor = "#cdd6f4"
, manageHook = manageDocks <+> myManageHooks
, startupHook = myStartupHook
, logHook = dynamicLogWithPP myXmobarPP
}
`additionalKeysP` myKeys
myconfig = def
{
modMask = mod4Mask
, layoutHook = myLayout
, terminal = "alacritty"
, normalBorderColor = "#f5c2e7"
, focusedBorderColor = "#cdd6f4"
, manageHook = myManageHooks
, startupHook = myStartupHook
}
`additionalKeysP`
[
-- Messages
("M-m w", spawn "xmessage 'Test Message :)'") -- type mod+x then w to pop up 'woohoo!')
-- System
myKeys =
[ -- Messages
("M-m w", spawn "xmessage 'Test Message :)'") -- type mod+x then w to pop up 'woohoo!')
-- System
, ("M-p", spawn "rofi -show \"drun\"")
-- Screenshots
, ("<Print>", spawn "maim --format=png \"/home/$USER/Pictures/screenshot-$(date -u +%Y-%m-%d-%H:%M:%S).png\"") -- Whole Screen to File
, -- Screenshots
("<Print>", spawn "maim --format=png \"/home/$USER/Pictures/screenshot-$(date -u +%Y-%m-%d-%H:%M:%S).png\"") -- Whole Screen to File
, ("M-<Print>", spawn "maim --format=png --window $(xdotool getactivewindow) \"/home/$USER/Pictures/screenshot-$(date -u +%Y-%m-%d-%H:%M:%S).png\"") -- Focused Window to File
, ("S-<Print>", spawn "maim --format=png --select \"/home/$USER/Pictures/screenshot-$(date -u +%Y-%m-%d-%H:%M:%S).png\"") -- Selection to File
, ("C-<Print>", spawn "maim --format=png | xclip -selection clipboard -t image/png") -- Whole Screen to Clipboard
, ("M-C-<Print>", spawn "maim --format=png --window $(xdotool getactivewindow) | xclip -section clipboard -t image/png") -- Focused Window to Clipboard
, ("C-S-<Print>", spawn "maim --format=png --select | xclip -selection clipboard -t image/png") -- Selection to Clipboard
--Program
-- Program
, ("M-c", spawn "firefox")
, ("M-y", spawn "signal-desktop")
, ("M-x", spawn "telegram-desktop")
, ("M-c", spawn "firefox")
, ("M-v", spawn "thunderbird")
-- Brightness
, ("<XF86MonBrightnessUp>", spawn "xbacklight -inc 10")
, -- Brightness
("<XF86MonBrightnessUp>", spawn "xbacklight -inc 10")
, ("<XF86MonBrightnessDown>", spawn "xbacklight -dec 10")
-- Audio
, ("<XF86AudioMute>", spawn "pulseaudio-ctl mute")
, -- Audio
("<XF86AudioMute>", spawn "pulseaudio-ctl mute")
, ("<XF86AudioRaiseVolume>", spawn "pulseaudio-ctl up 5")
, ("<XF86AudioLowerVolume>", spawn "pulseaudio-ctl down 5")
, ("<XF86AudioMicMute>", spawn "pulseaudio-ctl mute-input")
]
--`removeKeysP` [ "M-S-q" ]
]
-- `removeKeysP` [ "M-S-q" ]
myXmobarPP :: PP
myXmobarPP = def
{
ppSep = pink ""
, ppWsSep = ""
, ppCurrent = wrap " " "" . xmobarBorder "Top" "#f38ba8" 2
, ppVisible = wrap " " "" . xmobarBorder "Top" "#a6e3a1" 2
, ppHidden = green . wrap " " ""
, ppHiddenNoWindows = gray . wrap " " ""
, ppUrgent = red . wrap (yellow "!") (yellow "!")
, ppTitleSanitize = xmobarStrip
, ppOrder = \[ws, l, _, wins] -> [ws, l, wins]
, ppExtras = [logTitles formatFocused formatUnfocused]
}
myXmobarPP =
def
{ ppOutput = \str -> do
writeFile "/tmp/xmonad-eww-log" str
, ppCurrent = wrap "[[" "]]"
, ppVisible = wrap "(" ")"
, ppHidden = wrap " " " "
, ppHiddenNoWindows = id
, ppUrgent = wrap "!" "!"
, ppSep = " "
, ppOrder = \(ws : _ : _ : wins : _) -> [ws, wins]
, ppExtras = [logTitles formatFocused formatUnfocused]
}
where
formatFocused = wrap "[" "]" . pink . ppWindow
formatUnfocused = wrap "[" "]" . gray . ppWindow
formatFocused = wrap "*" "*" . ppWindow
formatUnfocused = id . ppWindow
ppWindow :: String -> String
ppWindow = xmobarRaw . (\w -> if null w then "???" else w) . shorten 15 -- set maximum length of windowtitle to 15
ppWindow w = if null w then "???" else take 30 w
pink, gray, red, yellow, green :: String -> String
pink = xmobarColor "#f5c2e7" ""
green = xmobarColor "#a6e3a1" ""
gray = xmobarColor "#cdd6f4" ""
red = xmobarColor "#f38ba8" ""
yellow = xmobarColor "#f9e2af" ""
myLayout = Tall 1 (3/100) (1/2) ||| Mirror (Tall 1 (3/100) (1/2)) ||| Full ||| ThreeColMid 1 (3/100) (1/2) -- wenn wieder zoom von fokusierten Seitenfenstern gewünscht, dann Fireox fixn und: magnifiercz' 1.3 (ThreeColMid 1 (3/100) (1/2))
myLayout = Tall 1 (3 / 100) (1 / 2) ||| Mirror (Tall 1 (3 / 100) (1 / 2)) ||| Full ||| ThreeColMid 1 (3 / 100) (1 / 2) -- wenn wieder zoom von fokusierten Seitenfenstern gewünscht, dann Fireox fixn und: magnifiercz' 1.3 (ThreeColMid 1 (3/100) (1/2))
myManageHooks :: ManageHook
myManageHooks = composeAll
[
isDialog --> doFloat
, className =? "Xmessage" --> doCenterFloat
]
myManageHooks =
composeAll
[ isDialog --> doFloat
, className =? "Xmessage" --> doCenterFloat
]
myStartupHook :: X ()
myStartupHook = do
mapM_ spawnOnce ["xmobar -x " ++ show sid | sid <- [0..9]]
spawnOnce "dropbox"
spawnOnce "nextcloud --background"
spawnOnce "nextcloud --background"
spawnOnce "trayer --edge top --align left --widthtype request --height 25 --transparent true --alpha 0 --expand false --SetDockType true --SetPartialStrut true --monitor primary &"
spawnOnce "eww open bar"