Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7845381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:12:18+00:00 2026-06-02T17:12:18+00:00

I’m a Haskell beginner and I’m using xmonad. I’m trying to make it prompt

  • 0

I’m a Haskell beginner and I’m using xmonad. I’m trying to make it prompt me before quitting as I occasionally hit mod+q by accident. I’ve found two ways of doing that, but I must be doing something wrong because neither of them work for me:
https://bbs.archlinux.org/viewtopic.php?id=120298
http://comments.gmane.org/gmane.comp.lang.haskell.xmonad/11699

Here’s my xmonad.hs:

import XMonad
import XMonad.Config.Gnome
import XMonad.Actions.Plane
import XMonad.Util.EZConfig
import XMonad.Util.Run(spawnPipe)
import qualified Data.Map as M
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import System.IO(Handle, hPutStrLn)
import System.Exit
import Control.Monad
import XMonad
import XMonad.Util.EZConfig
import XMonad.Util.Dmenu
import XMonad.Util.Run

workspaces' = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]

quit_confirm :: X ()
quit_confirm = do
  let m = "confirm restart"
  s <- dmenu [m]
  when (m == s) (spawn "xmonad --restart")

conf_quit = do
  response <- runProcessWithInput "dmenu" ["-p", "Quit?"] "yes\nno\n"
  when (response == "yes") (spawn "xmonad --restart")

main = do
        dzen2Pipe <- spawnPipe "dzen2 -w 1200 -xs 1 -ta l -fn '-*-terminus-*-*-*-*-16-*-*-*-*-*-*-*' -bg black -fg #d3d7cf "
        dzen2Right <- spawnPipe "~/.xmonad/status-dzen.sh"
        startupProgs <- spawnPipe "~/.xmonad/startups.sh"
        xmonad $ defaultConfig
             {
             workspaces = workspaces'
             , manageHook = manageHook' <+> manageHook defaultConfig
             , modMask = mod4Mask
             , terminal = "gnome-terminal"
     , layoutHook = layoutHook'
         , logHook = logHook' dzen2Pipe
             }
            `additionalKeysP`
               [ -- Lock Screen
                ("M-S-l",    spawn "gnome-screensaver-command -l")
                -- Sleep
                , ("M-S-;",   spawn "gnome-screensaver-command -l; pmi action suspend")
                -- wireless
                , ("M-S-C-w", spawn "~/.xmonad/wireless.sh")
                -- 1 screen reconf
                , ("M-S-C-1", spawn "~/.xmonad/1-screen.sh")
                -- 2 screen reconf
                , ("M-S-C-2", spawn "~/.xmonad/2-screen.sh")
                -- confirm for quit
                , ("M-q", conf_quit)
                ]
             `additionalKeys`
             M.toList (planeKeys mod4Mask GConf Finite)

layoutHook' = avoidStruts $ layoutHook defaultConfig

logHook' = dynamicLogWithPP . dzenPP'

dzenPP' h = defaultPP
            {
            ppOutput = hPutStrLn h
            }

manageHook' = composeAll
  [ className =? "Pidgin" --> doShift "1" ,
    className =? "Firefox" --> doShift "2" ,
    className =? "Thunderbird" --> doShift "3" ,
    className =? "OpenOffice.org 3.2" --> doShift "4",
    manageDocks ]

Thanks!

Edit: the menu is displayed, but spawn process doesn’t seem to work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:12:19+00:00Added an answer on June 2, 2026 at 5:12 pm

    The answers others gave missed that dmenu seems to add an extra whitespace to the end of the string it returns. You just need to do the following and it works for me:

    confirm :: String -> X () -> X ()
    confirm m f = do
      result <- dmenu [m]
      when (init result == m) f
    

    And then, as @mariop suggested use either

    confirm "Restart" $ spawn "xmonad --recompile && xmonad --restart"
    

    or

    confirm "Exit" $ io (exitWith ExitSuccess)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.