From 499bb6a2d9f08c3fad40297a13d63c35c42ec260 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sat, 23 Mar 2024 12:48:35 +0530 Subject: added a TreeSelect Menu --- .config/XMonad/lib/Defaults.hs | 45 ++++++++++++++++-- .config/XMonad/lib/Keybindings.hs | 99 +++++++++++++++++++++------------------ .config/XMonad/lib/Scratchpads.hs | 8 +--- .config/XMonad/lib/TreeSelect.hs | 93 ++++++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+), 55 deletions(-) create mode 100644 .config/XMonad/lib/TreeSelect.hs (limited to '.config/XMonad/lib') diff --git a/.config/XMonad/lib/Defaults.hs b/.config/XMonad/lib/Defaults.hs index 8492cd7..5eeb0a8 100644 --- a/.config/XMonad/lib/Defaults.hs +++ b/.config/XMonad/lib/Defaults.hs @@ -3,6 +3,7 @@ module Defaults where import XMonad import XMonad.Layout.Spacing import XMonad.Layout.Tabbed +import qualified XMonad.Actions.TreeSelect as TS import XMonad.Actions.GridSelect import XMonad.Util.Loggers @@ -34,6 +35,9 @@ myTerminal = "open_terminal" myTerminal' = "WINIT_X11_SCALE_FACTOR=1.5 alacritty" myLauncher = "dmenu_run" +prevTrack = "playerctl previous" +nextTrack = "playerctl next" +stopTrack = "playerctl stop" pausePlay = "playerctl play-pause" volUp = "pamixer -i 5" @@ -52,8 +56,8 @@ customScreenshot = "flameshot gui" myBrowser = "librewolf" myPrivateBrowser = "librewolf --private-window" -myBrowser' = "firefox" -myPrivateBrowser' = "firefox --private-window" +myBrowser' = "vivaldi" +myPrivateBrowser' = "vivaldi --incognito" myTorrentClient = "qbittorrent" @@ -61,15 +65,32 @@ myFileManager = "pcmanfm" myFileManager' = "lf" myTextEditor = "doom run" -myTextEditor' = "nvim" +myTextEditor' = "codium" +myTermTextEditor = "nvim" myEmailClient = "thunderbird" myPasswordManager = "keepassxc" +myDiscord = "firejail discord" + +myDisplayMenu = "arandr" +myWallpaperMenu = "nitrogen" +myCalculator = "galculator" + -- workspaces myExtraWorkspaces = [(xK_0, "十")] myWorkspaces = ["一", "二", "三", "四", "五", "六", "七", "八", "九"] ++ map snd myExtraWorkspaces +-- links +myWebsite = "https://vidhukant.com" +myGitServer = "https://mikunonaka.net" +myGitHubProfile = "https://github.com/MikunoNaka" +myYTChannel = "https://www.youtube.com/@MikunoNakaZT" +myMALProfile = "https://myanimelist.net/profile/0ZeroTsu" +myCloud = "https://cloud.vidhukant.com" +vpsDashboard = "https://cloud.linode.com/linodes" +dnsDashboard = "https://cloud.linode.com/domains" + -- screen gaps sGap = 3 wGap = 4 @@ -87,6 +108,24 @@ myTabTheme = def { , inactiveTextColor = "#d0d0d0" , decoHeight = 20 } + +--myBorder' = "#c678dd" +myTSConfig = TS.TSConfig { + TS.ts_hidechildren = True + , TS.ts_background = 0xb30e0911 + , TS.ts_font = myFont + , TS.ts_node = (0xffd0d0d0, 0xff1c1f24) + , TS.ts_nodealt = (0xffd0d0d0, 0xff282c34) + , TS.ts_highlight = (0xffffffff, 0xff755999) + , TS.ts_extra = 0xffffffff + , TS.ts_node_width = 220 + , TS.ts_node_height = 28 + , TS.ts_originX = 0 + , TS.ts_originY = 0 + , TS.ts_indent = 80 + , TS.ts_navigate = TS.defaultNavigation +} + myGSColorizer :: Window -> Bool -> X (String, String) myGSColorizer = colorRangeFromClassName (0x28,0x2c,0x34) -- lowest inactive bg diff --git a/.config/XMonad/lib/Keybindings.hs b/.config/XMonad/lib/Keybindings.hs index bc1aa99..224139a 100644 --- a/.config/XMonad/lib/Keybindings.hs +++ b/.config/XMonad/lib/Keybindings.hs @@ -23,6 +23,7 @@ import XMonad.Hooks.ManageDocks import Util import Defaults +import TreeSelect import Scratchpads myMouseKeybindings :: [((ButtonMask, Button), Window -> X ())] @@ -37,12 +38,21 @@ myFnKeybindingsP :: [(String, X())] myFnKeybindingsP = [ ("", spawn backlightUp) , ("", spawn backlightDown) + , ("", spawn volUp) , ("", spawn volDown) , ("", spawn volMute) + + , ("", spawn prevTrack) + , ("", spawn nextTrack) + , ("", spawn stopTrack) , ("", spawn pausePlay) , ("", spawn pausePlay) , ("", spawn pausePlay) + + , ("", spawn myCalculator) + , ("", spawn myDisplayMenu) + , ("", spawn myEmailClient) ] myKeybindings :: [((KeyMask, KeySym), X ())] @@ -50,72 +60,71 @@ myKeybindings = [ ((myModMask, xK_Return), spawn myTerminal) , ((myModShiftMask, xK_Return), spawn myLockscreen) , ((myModMask .|. shiftMask, xK_c), kill1) - , ((myModMask, xK_s), spawn myLauncher) + + , ((myModMask, xK_s), showTS myMainTS) + , ((myModShiftMask, xK_s), spawn myLauncher) -- view prev/next workspaces - , ((myModShiftMask, xK_Tab ), prevWS) - , ((myModMask, xK_Tab ), nextWS) - --, ((myModMask, xK_semicolon ), prevWS) - --, ((myModMask, xK_apostrophe), nextWS) - --, ((myModMask', xK_h ), prevWS) - --, ((myModMask', xK_l ), nextWS) + , ((myModMask', xK_h ), prevWS) + , ((myModMask', xK_l ), nextWS) -- move to prev/next workspaces - --, ((myModShiftMask', xK_h ), shiftToPrev >> prevWS) - --, ((myModShiftMask', xK_l ), shiftToNext >> nextWS) - --, ((myModShiftMask', xK_semicolon ), shiftToPrev >> prevWS) - --, ((myModShiftMask', xK_apostrophe), shiftToNext >> nextWS) + , ((myModShiftMask', xK_h ), shiftToPrev >> prevWS) + , ((myModShiftMask', xK_l ), shiftToNext >> nextWS) -- toggle maximize - --, ((myModMask, xK_f), withFocused (sendMessage . maximizeRestore)) + , ((myModMask, xK_f), withFocused (sendMessage . maximizeRestore)) -- unfloat windows - --, ((myModMask .|. shiftMask, xK_f), withFocused $ windows . W.sink) + , ((myModMask .|. shiftMask, xK_f), withFocused $ windows . W.sink) -- cycle through windows - --, ((myModMask', xK_j), windows W.focusDown) - --, ((myModMask', xK_k), windows W.focusUp) + , ((myModMask, xK_Tab), windows W.focusUp) + , ((myModShiftMask, xK_Tab), windows W.focusDown) -- 2D navigation - , ((myModMask, xK_n), sendMessage $ Go R) - , ((myModMask, xK_d), sendMessage $ Go L) - , ((myModMask, xK_t), sendMessage $ Go U) - , ((myModMask, xK_h), sendMessage $ Go D) + , ((myModMask, xK_l), sendMessage $ Go R) + , ((myModMask, xK_h), sendMessage $ Go L) + , ((myModMask, xK_k), sendMessage $ Go U) + , ((myModMask, xK_j), sendMessage $ Go D) -- swap windows - , ((myModShiftMask, xK_n), sendMessage $ WN.Swap R) - , ((myModShiftMask, xK_d), sendMessage $ WN.Swap L) - , ((myModShiftMask, xK_t), sendMessage $ WN.Swap U) - , ((myModShiftMask, xK_h), sendMessage $ WN.Swap D) + , ((myModShiftMask, xK_l), sendMessage $ WN.Swap R) + , ((myModShiftMask, xK_h), sendMessage $ WN.Swap L) + , ((myModShiftMask, xK_k), sendMessage $ WN.Swap U) + , ((myModShiftMask, xK_j), sendMessage $ WN.Swap D) -- resize - , ((myModMask .|. myModMask', xK_n), sendMessage $ ExpandTowards R) - , ((myModMask .|. myModMask', xK_d), sendMessage $ ExpandTowards L) - , ((myModMask .|. myModMask', xK_h), sendMessage $ ExpandTowards D) - , ((myModMask .|. myModMask', xK_t), sendMessage $ ExpandTowards U) - , ((myModMask .|. myModShiftMask', xK_n), sendMessage $ ShrinkFrom R) - , ((myModMask .|. myModShiftMask', xK_d), sendMessage $ ShrinkFrom L) - , ((myModMask .|. myModShiftMask', xK_h), sendMessage $ ShrinkFrom D) - , ((myModMask .|. myModShiftMask', xK_t), sendMessage $ ShrinkFrom U) - --, ((myModMask, xK_B), windows $ W.greedyView "十") + , ((myModMask .|. myModMask', xK_h), sendMessage $ ExpandTowards R) + , ((myModMask .|. myModMask', xK_l), sendMessage $ ExpandTowards L) + , ((myModMask .|. myModMask', xK_j), sendMessage $ ExpandTowards D) + , ((myModMask .|. myModMask', xK_k), sendMessage $ ExpandTowards U) + , ((myModMask .|. myModShiftMask', xK_h), sendMessage $ ShrinkFrom R) + , ((myModMask .|. myModShiftMask', xK_l), sendMessage $ ShrinkFrom L) + , ((myModMask .|. myModShiftMask', xK_j), sendMessage $ ShrinkFrom D) + , ((myModMask .|. myModShiftMask', xK_k), sendMessage $ ShrinkFrom U) ] ++ [ -- workspace switching - ((myModMask, key), windows $ W.greedyView ws) | (key,ws) <- myExtraWorkspaces - -- ] ++ [ - -- -- moving window to workspace - -- ((myModShiftMask, key), windows $ W.shift ws) | (key,ws) <- myWorkspaces - -- ] ++ [ - -- -- to swap workspace - -- ((myModShiftMask', key), windows $ swapWithCurrent ws) | (key, ws) <- myWorkspaces + ((myModMask, key), windows $ W.greedyView ws) + | (key,ws) <- myExtraWorkspaces + ] ++ [ + -- moving window to workspace + ((myModShiftMask, key), windows $ W.shift ws) + | (key,ws) <- myExtraWorkspaces + ] ++ [ + -- to swap workspace + -- TODO: try to change this into a key chord + ((myModShiftMask', key), windows $ swapWithCurrent ws) + | (key, ws) <- zip [xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_8, xK_0] myWorkspaces -- ] ++ [ -- -- copy -- ((m .|. myModMask, key), windows $ f ws) | (key, ws) <- myWorkspaces, (f, m) <- [(copy, myModShiftMask')] -- ] ++ [ -- -- for not swapping tags while using multihead -- ((m .|. myModMask, key), windows $ f ws) | (key, ws) <- myWorkspaces, (f, m) <- [(W.view, 0), (W.shift, shiftMask)] - ] -- ++ [ -- directly focus monitors instead of cycling - -- ((m .|. myModMask, key), screenWorkspace sc >>= flip whenJust (windows . f)) - -- | (key, sc) <- zip [xK_e, xK_w] [0..] - -- , (f, m) <- [(W.view, 0), (W.shift, shiftMask)] - --] + ] ++ [ -- directly focus monitors instead of cycling + ((m .|. myModMask, key), screenWorkspace sc >>= flip whenJust (windows . f)) + | (key, sc) <- zip [xK_m, xK_w] [0..] + , (f, m) <- [(W.view, 0), (W.shift, shiftMask)] + ] myKeybindingsP :: [(String, X())] -myKeybindingsP = [] \ No newline at end of file +myKeybindingsP = [] diff --git a/.config/XMonad/lib/Scratchpads.hs b/.config/XMonad/lib/Scratchpads.hs index d0055c7..a2b6e30 100644 --- a/.config/XMonad/lib/Scratchpads.hs +++ b/.config/XMonad/lib/Scratchpads.hs @@ -10,14 +10,10 @@ import Defaults myScratchpad :: String -> X () myScratchpad x = namedScratchpadAction myScratchpads x --- if I try to concatinate strings directly --- it won't compile for some reason term0Cmd = myTerminal' ++ " -t 'Term U'" term1Cmd = myTerminal' ++ " -t 'Term I'" term2Cmd = myTerminal' ++ " -t 'Term O'" term3Cmd = myTerminal' ++ " -t 'Term P'" -lfCmd = myTerminal' ++ " -t 'lf' -e 'lf'" -nmtuiCmd = myTerminal' ++ " -t 'nmtui' -e 'nmtui'" bpytopCmd = myTerminal' ++ " -t 'BPYTOP' -e 'bpytop'" playerCmd = myTerminal' ++ " -t 'NCMPCPP' -e 'ncmpcpp'" @@ -26,12 +22,10 @@ myScratchpads = , NS "Term 1" term1Cmd (title =? "Term I") (customFloating $ W.RationalRect (1/16) (1/16) (7/8) (7/8)) , NS "Term 2" term2Cmd (title =? "Term O") (customFloating $ W.RationalRect (1/16) (1/16) (7/8) (7/8)) , NS "Term 3" term3Cmd (title =? "Term P") (customFloating $ W.RationalRect (1/16) (1/16) (7/8) (7/8)) - , NS "lf" lfCmd (title =? "lf") (customFloating $ W.RationalRect (1/16) (1/16) (7/8) (7/8)) , NS "BPYTOP" bpytopCmd (title =? "BPYTOP") (customFloating $ W.RationalRect (1/16) (1/16) (7/8) (7/8)) , NS "musicplayer" playerCmd (title =? "NCMPCPP") (customFloating $ W.RationalRect (1/16) (1/16) (7/8) (7/8)) - , NS "nmtui" nmtuiCmd (title =? "nmtui") (customFloating $ W.RationalRect (1/4) (1/8) (1/2) (3/4)) , NS "arandr" "arandr" (className =? "Arandr") (customFloating $ W.RationalRect (1/4) (1/4) (1/2) (1/2)) - , NS "calc" "galculator" (className =? "Galculator") (customFloating $ W.RationalRect (5/13) (4/13) (3/13) (6/13)) + , NS "calc" myCalculator (className =? "Galculator") (customFloating $ W.RationalRect (5/13) (4/13) (3/13) (6/13)) , NS "blueman" "blueman-manager" (className =? "Blueman-manager") (customFloating $ W.RationalRect (5.5/16) (4/13) (5/16) (6/13)) , NS "pavucontrol" "pavucontrol" (className =? "Pavucontrol") (customFloating $ W.RationalRect (3/12) (1/12) (3/6) (5/6)) , NS "wallpaper" "nitrogen" (className =? "Nitrogen") (customFloating $ W.RationalRect (3/12) (1/12) (3/6) (5/6)) diff --git a/.config/XMonad/lib/TreeSelect.hs b/.config/XMonad/lib/TreeSelect.hs new file mode 100644 index 0000000..803789f --- /dev/null +++ b/.config/XMonad/lib/TreeSelect.hs @@ -0,0 +1,93 @@ +module TreeSelect where + +import Data.Tree + +import XMonad +import qualified XMonad.StackSet as W + +import XMonad.Actions.TreeSelect + +import Defaults + +showTS x = treeselectAction myTSConfig x + +myBrowserTS :: Forest (TSNode (X ())) +myBrowserTS = [ + Node (TSNode "LibreWolf" "The default" (spawn myBrowser)) [] + , Node (TSNode "LibreWolf (private)" "" (spawn myPrivateBrowser)) [] + , Node (TSNode "Vivaldi" "" (spawn myBrowser')) [] + , Node (TSNode "TOR" "" (spawn "torbrowser-launcher")) [] + , Node (TSNode "Firefox" "" (spawn "firefox")) [] + , Node (TSNode "Brave" "" (spawn "brave")) [] + ] + +myEditingTS :: Forest (TSNode (X ())) +myEditingTS = [ + Node (TSNode "GIMP" "Hackerman's photoshop" (spawn "gimp")) [] + , Node (TSNode "Kdenlive" "Main video editor" (spawn "kdenlive")) [] + , Node (TSNode "Audacity" "" (spawn "audacity")) [] + , Node (TSNode "OBS" "" (spawn "obs-studio")) [] + , Node (TSNode "Canva" "Zoomer's photoshop" (spawn $ myBrowser ++ " https://canva.com")) [] + ] + +myDevTS :: Forest (TSNode (X ())) +myDevTS = [ + Node (TSNode "Doom Emacs" "" (spawn myTextEditor)) [] + , Node (TSNode "VSC" "VSCodium" (spawn myTextEditor')) [] + , Node (TSNode "Postman" "" (spawn "postman")) [] + , Node (TSNode "Virt Manager" "" (spawn "virt-manager")) [] + , Node (TSNode "IntelliJ IDEA" "Java IDE" (spawn "idea")) [] + , Node (TSNode "Android Studio" "" (spawn "android-studio")) [] + , Node (TSNode "PyCharm" "Python IDE" (spawn "pycharm")) [] + ] + +myUtilTS :: Forest (TSNode (X ())) +myUtilTS = [ + Node (TSNode "File Manager" "" (spawn myFileManager)) [] + , Node (TSNode "Volume Control" "pavucontrol" (spawn "pavucontrol")) [] + , Node (TSNode "Cloud" "Nextcloud" (spawn $ myBrowser ++ " " ++ myCloud)) [] + , Node (TSNode "Calculator" "" (spawn myCalculator)) [] + , Node (TSNode "Screenshot" "" (spawn fullScreenshot)) [] + , Node (TSNode "Torrent" "" (spawn myTorrentClient)) [] + , Node (TSNode "Email Client" "" (spawn myEmailClient)) [] + , Node (TSNode "Screen Recorder" "OBS" (spawn "obs-studio")) [] + , Node (TSNode "Wallpapers" "" (spawn myWallpaperMenu)) [] + , Node (TSNode "Google Docs" "" (spawn $ myBrowser ++ " https://docs.google.com")) [] + , Node (TSNode "Google Sheets" "" (spawn $ myBrowser ++ " https://sheets.google.com")) [] + , Node (TSNode "Google Slides" "" (spawn $ myBrowser ++ " https://slides.google.com")) [] + , Node (TSNode "Google Forms" "" (spawn $ myBrowser ++ " https://forms.google.com")) [] + ] + +myLinksTS :: Forest (TSNode (X ())) +myLinksTS = [ + Node (TSNode "Linode Dashboard" "" (spawn $ myBrowser ++ " " ++ vpsDashboard)) [] + , Node (TSNode "Linode Dashboard (DNS)" "" (spawn $ myBrowser ++ " " ++ dnsDashboard)) [] + , Node (TSNode "Git Server" "MikunoNaka.net" (spawn $ myBrowser ++ " " ++ myGitServer)) [] + , Node (TSNode "GitHub" "My GitHub Profile" (spawn $ myBrowser ++ " " ++ myGitHubProfile)) [] + , Node (TSNode "MyAnimeList" "My MAL Profile" (spawn $ myBrowser ++ " " ++ myMALProfile)) [] + , Node (TSNode "My Website" "VidhuKant.com" (spawn $ myBrowser ++ " " ++ myWebsite)) [] + , Node (TSNode "Cloud Storage" "Nextcloud" (spawn $ myBrowser ++ " " ++ myCloud)) [] + , Node (TSNode "YouTube Channel" "" (spawn $ myBrowser ++ " " ++ myYTChannel)) [] + , Node (TSNode "WhatsApp Web" "" (spawn $ myBrowser ++ " https://web.whatsapp.com")) [] + , Node (TSNode "Google Docs" "" (spawn $ myBrowser ++ " https://docs.google.com")) [] + , Node (TSNode "Google Sheets" "" (spawn $ myBrowser ++ " https://sheets.google.com")) [] + , Node (TSNode "Google Slides" "" (spawn $ myBrowser ++ " https://slides.google.com")) [] + , Node (TSNode "Google Forms" "" (spawn $ myBrowser ++ " https://forms.google.com")) [] + ] + +myPowerTS :: Forest (TSNode (X ())) +myPowerTS = [ + Node (TSNode "Shut Down" "" (spawn "shutdown now")) [] + , Node (TSNode "Reboot" "" (spawn "reboot")) [] + ] + +myMainTS :: Forest (TSNode (X ())) +myMainTS = [ + Node (TSNode "Web Browser" "Open for more options" (spawn myBrowser)) myBrowserTS + , Node (TSNode "Discord" "Zoomer's Spyware" (spawn myDiscord)) [] + , Node (TSNode "Editing" "Makin' memes" (return())) myEditingTS + , Node (TSNode "Development" "Hackering tools" (return())) myDevTS + , Node (TSNode "Utilities" "Misc n settings" (return())) myUtilTS + , Node (TSNode "Links" "Commonly visited sites" (return())) myLinksTS + , Node (TSNode "Power" "" (return())) myPowerTS + ] -- cgit v1.2.3