I use this truly excellent Firefox add-on: https://github.com/docwhat/itsalltext/
Hit ctrl-e to edit any textarea in Vim.
However vim starts up tiled. My browser workspaces are single-window tabbed, so a fullscreen editor is overkill. Here's what I tried to make it start as a floating window:
-- This works, but matches any vim instance, not just itsalltext instances:
-- , className =? "Gvim" --> doFloat
-- This does nothing:
, fmap (isInfixOf "itsalltext") title --> doFloat
xprop shows this for the window that is created:
WM_CLASS(STRING) = "gvim", "Gvim"
WM_ICON_NAME(STRING) = "mail.google.com.3c1b1v2w21.txt (~/.mozilla/firefox/3waevusx.default/itsalltext) - GVIM1"
_NET_WM_ICON_NAME(UTF8_STRING) = "mail.google.com.3c1b1v2w21.txt (~/.mozilla/firefox/3waevusx.default/itsalltext) - GVIM1"
WM_NAME(STRING) = "mail.google.com.3c1b1v2w21.txt (~/.mozilla/firefox/3waevusx.default/itsalltext) - GVIM1"
_NET_WM_NAME(UTF8_STRING) = "mail.google.com.3c1b1v2w21.txt (~/.mozilla/firefox/3waevusx.default/itsalltext) - GVIM1"
Bonus question: doFloat works, but I'd really like to specify how to float. For scratchpads, this works:
customFloating $ W.RationalRect (1/6) (1/6) (2/3) (2/3)
But I couldn't figure out how to use customFloating for a window that's not a scratchpad.
Related
i am playing with wxPython and try to set position of frame:
import wx
app = wx.App()
p = wx.Point(200, 200)
frame = wx.Frame(None, title = 'test position', pos = p)
frame.Show(True)
print('frame position: ', frame.GetPosition())
app.MainLoop()
even though print('frame position: ', frame.GetPosition()) shows the correct postion, the frame is shown in top left corner of screen.
Alternatively i tried
frame.SetPosition(p)
frame.Move(p)
without success.
my environment: ArchLinux 5.3.13, python 3.8.0, wxpython 4.0.7, openbox 3.6.1
On cinnamom the code works as expected. How to solve this on openbox?
edit 07,12,2019:
i could set postion of a dialog in openbox config ~/.config/openbox/rc.xml:
<application name="fahrplan.py"
class="Fahrplan.py"
groupname="fahrplan.py"
groupclass="Fahrplan.py"
title="Fahrplan *"
type="dialog">
<position force="no">
<x>760</x>
<y>415</y>
</position>
</application>
i got name, class etc. from obxprop. x and y are calculated to center a dialog of 400 x 250 px on screen of 1920 x 1080 px.
This static solution is not suitable for me. I want to place dynamically generated popups.
I had the same problem under Windows and played around with the style flags. With wxICONIZE sytle set active the window finally used the positioning information
The position is provided to the window manager as a "hint". It is totally up to the window manager whether it will actually honor the hint or not. Check the openbox settings or preferences and see if there is anything relevant that can be changed.
how can I setup XMonad to work with two monitors? I have a laptop and when at my desk I plug a second monitor on the HDMI port.
With the monitor plugged and activated, XMonad thinks I have a single very wide screen. I3 works good; I have different workspaces for different monitors.
import System.IO
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Util.Run (spawnPipe)
import qualified Data.Map as M
main =
xmonad =<<
xmobar
defaultConfig
{ terminal = "alacritty"
, manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, handleEventHook = mconcat [docksEventHook, handleEventHook defaultConfig]
, borderWidth = 2
, modMask = mod4Mask
, keys = mykeys
}
mykeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
mykeys c = (myKeys c) `M.union` (XMonad.keys defaultConfig c)
where
myKeys (XConfig {modMask = modm}) = myKeyBindings modm
myKeyBindings modm = M.fromList $ []
This is my xmonad.hs
My xorg.conf is:
➜ X11 cat xorg.conf
Section "ServerLayout"
Identifier "layout"
Screen 0 "nvidia"
Inactive "intel"
EndSection
Section "Device"
Identifier "intel"
Driver "modesetting"
BusID "PCI:0#0:2:0"
Option "AccelMethod" "None"
EndSection
Section "Screen"
Identifier "intel"
Device "intel"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:1#0:0:0"
Option "ConstrainCursor" "off"
EndSection
Section "Screen"
Identifier "nvidia"
Device "nvidia"
Option "AllowEmptyInitialConfiguration" "on"
Option "IgnoreDisplayDevices" "CRT"
EndSection
I run XMonad as my display manager on a multi-monitor setup, so I can help.
#1
XMonad is not what controls how the monitors are laid out / oriented; that is the job of X itself. You can play around with xrandr to get them laid out how you want. Just make sure both monitors can be detected, and then run this from the command line:
xrandr
That will give you all of your monitor info, like resolution and where it is plugged in.
(https://www.x.org/releases/X11R7.5/doc/man/man1/xrandr.1.html)
This is what I run in my .xinitrc before XMonad launches to configure my monitors:
xrandr --dpi 192
xrandr --output HDMI-0 --mode 1920x1080 --pos 0x0 --scale 1.5x1.5
xrandr --output HDMI-1 --mode 3840x2160 --pos 3840x0
Just make sure you switch out the output name, resolution, and position with how yours are laid out, and only configure the DPI / scale if the monitors have different resolutions.
#2
As far as configuring XMonad to have additional functionality regarding the two-monitor setup, you may want to check out XMonad.Actions.OnScreen from xmonad-contrib.
(https://xmonad.github.io/xmonad-docs/xmonad-contrib/XMonad-Actions-OnScreen.html)
Personally I use focusOnMouseMove from XMonad.Actions.UpdateFocus too, to switch the focus monitor when I move the cursor to the other monitor.
(https://hackage.haskell.org/package/xmonad-contrib-0.17.1/docs/XMonad-Actions-UpdateFocus.html#v:focusOnMouseMove)
You can have it set up like this on your .profile.
xrandr --output name_of_primary_display --mode ResxRes --left/right/top/bottom-of secondary-display --auto &
I have the following code block in my .lhs file which uses inline TeX comments:
\begin{code}
main = print 0
{-"$\langle$Link$\rangle$"-}
\end{code}
However, after compiling with lhs2TeX, I get the following errors when compiling the generated .tex file:
! Missing $ inserted.
<inserted text>
$
l.269 \end{hscode}
\resethooks
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! LaTeX Error: Bad math environment delimiter.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.269 \end{hscode}
\resethooks
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
! Missing $ inserted.
<inserted text>
$
l.269 \end{hscode}
\resethooks
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! LaTeX Error: Bad math environment delimiter.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.269 \end{hscode}
\resethooks
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
! Missing $ inserted.
<inserted text>
$
l.269 \end{hscode}
\resethooks
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! LaTeX Error: Bad math environment delimiter.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.269 \end{hscode}
\resethooks
Your command was ignored.
When I remove the " marks in the inline comment, the error disappears. Anyone know what's wrong?
P.S Here's the .tex file that lhs2TeX generates:
\documentclass{article}%% ODER: format == = "\mathrel{==}"
%% ODER: format /= = "\neq "
%
%
\makeatletter
\#ifundefined{lhs2tex.lhs2tex.sty.read}%
{\#namedef{lhs2tex.lhs2tex.sty.read}{}%
\newcommand\SkipToFmtEnd{}%
\newcommand\EndFmtInput{}%
\long\def\SkipToFmtEnd#1\EndFmtInput{}%
}\SkipToFmtEnd
\newcommand\ReadOnlyOnce[1]{\#ifundefined{#1}{\#namedef{#1}{}}\SkipToFmtEnd}
\usepackage{amstext}
\usepackage{amssymb}
\usepackage{stmaryrd}
\DeclareFontFamily{OT1}{cmtex}{}
\DeclareFontShape{OT1}{cmtex}{m}{n}
{<5><6><7><8>cmtex8
<9>cmtex9
<10><10.95><12><14.4><17.28><20.74><24.88>cmtex10}{}
\DeclareFontShape{OT1}{cmtex}{m}{it}
{<-> ssub * cmtt/m/it}{}
\newcommand{\texfamily}{\fontfamily{cmtex}\selectfont}
\DeclareFontShape{OT1}{cmtt}{bx}{n}
{<5><6><7><8>cmtt8
<9>cmbtt9
<10><10.95><12><14.4><17.28><20.74><24.88>cmbtt10}{}
\DeclareFontShape{OT1}{cmtex}{bx}{n}
{<-> ssub * cmtt/bx/n}{}
\newcommand{\tex}[1]{\text{\texfamily#1}} % NEU
\newcommand{\Sp}{\hskip.33334em\relax}
\newcommand{\Conid}[1]{\mathit{#1}}
\newcommand{\Varid}[1]{\mathit{#1}}
\newcommand{\anonymous}{\kern0.06em \vbox{\hrule\#width.5em}}
\newcommand{\plus}{\mathbin{+\!\!\!+}}
\newcommand{\bind}{\mathbin{>\!\!\!>\mkern-6.7mu=}}
\newcommand{\rbind}{\mathbin{=\mkern-6.7mu<\!\!\!<}}% suggested by Neil Mitchell
\newcommand{\sequ}{\mathbin{>\!\!\!>}}
\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}
\usepackage{polytable}
%mathindent has to be defined
\#ifundefined{mathindent}%
{\newdimen\mathindent\mathindent\leftmargini}%
{}%
\def\resethooks{%
\global\let\SaveRestoreHook\empty
\global\let\ColumnHook\empty}
\newcommand*{\savecolumns}[1][default]%
{\g#addto#macro\SaveRestoreHook{\savecolumns[#1]}}
\newcommand*{\restorecolumns}[1][default]%
{\g#addto#macro\SaveRestoreHook{\restorecolumns[#1]}}
\newcommand*{\aligncolumn}[2]%
{\g#addto#macro\ColumnHook{\column{#1}{#2}}}
\resethooks
\newcommand{\onelinecommentchars}{\quad-{}- }
\newcommand{\commentbeginchars}{\enskip\{-}
\newcommand{\commentendchars}{-\}\enskip}
\newcommand{\visiblecomments}{%
\let\onelinecomment=\onelinecommentchars
\let\commentbegin=\commentbeginchars
\let\commentend=\commentendchars}
\newcommand{\invisiblecomments}{%
\let\onelinecomment=\empty
\let\commentbegin=\empty
\let\commentend=\empty}
\visiblecomments
\newlength{\blanklineskip}
\setlength{\blanklineskip}{0.66084ex}
\newcommand{\hsindent}[1]{\quad}% default is fixed indentation
\let\hspre\empty
\let\hspost\empty
\newcommand{\NB}{\textbf{NB}}
\newcommand{\Todo}[1]{$\langle$\textbf{To do:}~#1$\rangle$}
\EndFmtInput
\makeatother
%
%
%
%
%
%
% This package provides two environments suitable to take the place
% of hscode, called "plainhscode" and "arrayhscode".
%
% The plain environment surrounds each code block by vertical space,
% and it uses \abovedisplayskip and \belowdisplayskip to get spacing
% similar to formulas. Note that if these dimensions are changed,
% the spacing around displayed math formulas changes as well.
% All code is indented using \leftskip.
%
% Changed 19.08.2004 to reflect changes in colorcode. Should work with
% CodeGroup.sty.
%
\ReadOnlyOnce{polycode.fmt}%
\makeatletter
\newcommand{\hsnewpar}[1]%
{{\parskip=0pt\parindent=0pt\par\vskip #1\noindent}}
% can be used, for instance, to redefine the code size, by setting the
% command to \small or something alike
\newcommand{\hscodestyle}{}
% The command \sethscode can be used to switch the code formatting
% behaviour by mapping the hscode environment in the subst directive
% to a new LaTeX environment.
\newcommand{\sethscode}[1]%
{\expandafter\let\expandafter\hscode\csname #1\endcsname
\expandafter\let\expandafter\endhscode\csname end#1\endcsname}
% "compatibility" mode restores the non-polycode.fmt layout.
\newenvironment{compathscode}%
{\par\noindent
\advance\leftskip\mathindent
\hscodestyle
\let\\=\#normalcr
\let\hspre\(\let\hspost\)%
\pboxed}%
{\endpboxed\)%
\par\noindent
\ignorespacesafterend}
\newcommand{\compaths}{\sethscode{compathscode}}
% "plain" mode is the proposed default.
% It should now work with \centering.
% This required some changes. The old version
% is still available for reference as oldplainhscode.
\newenvironment{plainhscode}%
{\hsnewpar\abovedisplayskip
\advance\leftskip\mathindent
\hscodestyle
\let\hspre\(\let\hspost\)%
\pboxed}%
{\endpboxed%
\hsnewpar\belowdisplayskip
\ignorespacesafterend}
\newenvironment{oldplainhscode}%
{\hsnewpar\abovedisplayskip
\advance\leftskip\mathindent
\hscodestyle
\let\\=\#normalcr
\(\pboxed}%
{\endpboxed\)%
\hsnewpar\belowdisplayskip
\ignorespacesafterend}
% Here, we make plainhscode the default environment.
\newcommand{\plainhs}{\sethscode{plainhscode}}
\newcommand{\oldplainhs}{\sethscode{oldplainhscode}}
\plainhs
% The arrayhscode is like plain, but makes use of polytable's
% parray environment which disallows page breaks in code blocks.
\newenvironment{arrayhscode}%
{\hsnewpar\abovedisplayskip
\advance\leftskip\mathindent
\hscodestyle
\let\\=\#normalcr
\(\parray}%
{\endparray\)%
\hsnewpar\belowdisplayskip
\ignorespacesafterend}
\newcommand{\arrayhs}{\sethscode{arrayhscode}}
% The mathhscode environment also makes use of polytable's parray
% environment. It is supposed to be used only inside math mode
% (I used it to typeset the type rules in my thesis).
\newenvironment{mathhscode}%
{\parray}{\endparray}
\newcommand{\mathhs}{\sethscode{mathhscode}}
% texths is similar to mathhs, but works in text mode.
\newenvironment{texthscode}%
{\(\parray}{\endparray\)}
\newcommand{\texths}{\sethscode{texthscode}}
% The framed environment places code in a framed box.
\def\codeframewidth{\arrayrulewidth}
\RequirePackage{calc}
\newenvironment{framedhscode}%
{\parskip=\abovedisplayskip\par\noindent
\hscodestyle
\arrayrulewidth=\codeframewidth
\tabular{#{}|p{\linewidth-2\arraycolsep-2\arrayrulewidth-2pt}|#{}}%
\hline\framedhslinecorrect\\{-1.5ex}%
\let\endoflinesave=\\
\let\\=\#normalcr
\(\pboxed}%
{\endpboxed\)%
\framedhslinecorrect\endoflinesave{.5ex}\hline
\endtabular
\parskip=\belowdisplayskip\par\noindent
\ignorespacesafterend}
\newcommand{\framedhslinecorrect}[2]%
{#1[#2]}
\newcommand{\framedhs}{\sethscode{framedhscode}}
% The inlinehscode environment is an experimental environment
% that can be used to typeset displayed code inline.
\newenvironment{inlinehscode}%
{\(\def\column##1##2{}%
\let\>\undefined\let\<\undefined\let\\\undefined
\newcommand\>[1][]{}\newcommand\<[1][]{}\newcommand\\[1][]{}%
\def\fromto##1##2##3{##3}%
\def\nextline{}}{\) }%
\newcommand{\inlinehs}{\sethscode{inlinehscode}}
% The joincode environment is a separate environment that
% can be used to surround and thereby connect multiple code
% blocks.
\newenvironment{joincode}%
{\let\orighscode=\hscode
\let\origendhscode=\endhscode
\def\endhscode{\def\hscode{\endgroup\def\#currenvir{hscode}\\}\begingroup}
%\let\SaveRestoreHook=\empty
%\let\ColumnHook=\empty
%\let\resethooks=\empty
\orighscode\def\hscode{\endgroup\def\#currenvir{hscode}}}%
{\origendhscode
\global\let\hscode=\orighscode
\global\let\endhscode=\origendhscode}%
\makeatother
\EndFmtInput
%
\begin{document}\section{}Precis 0
\newline{}\subsubsection*{\texttt{test0.tweave:}}\begin{hscode}\SaveRestoreHook
\column{B}{#{}>{\hspre}l<{\hspost}#{}}%
\column{E}{#{}>{\hspre}l<{\hspost}#{}}%
\>[B]{}\Varid{main}\mathrel{=}\Varid{print}\;\mathrm{0}{}\<[E]%
\\
\>[B]{}$\langle$Link$\rangle${}\<[E]%
\ColumnHook
\end{hscode}\resethooks
\section{}Precis 1
\newline{}\subsubsection*{\texttt{test0.tweave:}}\begin{hscode}\SaveRestoreHook
\column{B}{#{}>{\hspre}l<{\hspost}#{}}%
\column{E}{#{}>{\hspre}l<{\hspost}#{}}%
\>[B]{}\Varid{accum}\;\Varid{i}\mathrel{=}\Varid{id}{}\<[E]%
\ColumnHook
\end{hscode}\resethooks
\end{document}
The {-" ... "-} construct is quite low-level. It drops you in the environment TeX currently is in, which happens to be math mode already. So the solution to your problem is simple. Write the code to be inserted as if you are in math mode.
A different option is to use a normal comment, but make the comment characters invisible using \invisiblecomments. Normal comments are typeset as text by lhs2TeX.
The following complete lhs2TeX document demonstrates both options:
\documentclass{article}
%include polycode.fmt
\begin{document}
% Assume you are in math mode already:
\begin{code}
main = print 0
{-"\langle\text{Link}\rangle"-}
\end{code}
% This works, too:
\invisiblecomments
\begin{code}
main = print 0
{- $\langle$Link$\rangle$ -}
\end{code}
\end{document}
I want to startup some applications in different workspaces(it is important) on xmonad start. So, I wrote following startupHook:
startupApps :: [String]
startupApps = ["konsole", "emacs", "firefox", "gvim", "konsole"]
startupSpawn :: X ()
startupSpawn = zipWithM_ id (map (spawnOn . show) [1..]) startupApps
But, it spawns all apps in first workspace. It seems to be part of more general problem -- if I start application, it get workspace not when it actually started, but when it loaded.
So, if I start firefox on WS1, then switch to WS2, firefox will spawn on WS2.
Still, what can I do about my intention?
You can use the manageHook to tell xmonad to move certain applications to certain desktops.
myManageHook = composeAll . concat $ [
[ className =? "Firefox" --> doF (shiftToWs 2) ]
, [ className =? "gvim" --> doF (shiftToWs 3) ]
-- and so on
]
The classNames might vary, though.
I'm trying to create my first "real program" in haskell (something that solves integrals if polynomials) but I'm completely stumped with this part of it:
I want to make something very simple a bit like GHCi:
> user input
program output
> user input
program output
> user input
program output
>
except that my program output is images (using LaTeX to turn mathematical expressions into PNGs) - so I can't do this using System.IO. I think it will be possible with gtk2hs which I've managed to install but I can't figure out how to make this input/output dialogue.
Please show me how it's done if you have the time. Thanks a lot!
We managed to come up with the following solution, thanks to ClaudiusMaximus.
module Main where
import Graphics.UI.Gtk
main = do
initGUI
----------------
win <- windowNew
onDestroy win mainQuit
vb <- vBoxNew False 3
log <- vBoxNew False 2
sc <- scrolledWindowNew Nothing Nothing
scrolledWindowSetPolicy sc PolicyNever PolicyAutomatic
sw <- layoutNew Nothing Nothing
en <- entryNew
----------------
scrolledWindowAddWithViewport sc log
boxPackStart vb sc PackGrow 0
boxPackStart vb en PackNatural 0
set win [ containerChild := vb ]
en `onEntryActivate` do
txt <- entryGetText en
entrySetText en ""
l <- labelNew (Just txt)
boxPackStart log l PackNatural 0
widgetShowAll log
Just ran <- scrolledWindowGetVScrollbar sc
adj <- rangeGetAdjustment ran
max <- adjustmentGetUpper adj
adjustmentSetValue adj max
----------------
widgetShowAll win
mainGUI
I think you should first implement the backend, i.e. the code for parsing a command and creating the output image. If that works, you could then implement the GUI. Basically, you need something light a text entry for input and an text and drawing widget for output. As GUI programming is (IMHO) not trivial, you should first look at some GTK/gtk2hs tutorials / introductions.