7

I am using Mathematica 12 on linux and would really like the dracula type theme for mathematica to match the overall theme of my system. I can use stylesheet to modify the notebook theme but this does not change the Menubar and the Scrollbars. Is there a way to change the colorscheme of the Menubar and the Scrollbars? Thanks for your time.

Carl Lange
  • 13,065
  • 1
  • 36
  • 70
Bimaphys
  • 73
  • 5
  • Unfortunately I don't know the answer, but it may also be helpful to mention what window manager you use. – Carl Lange Aug 31 '21 at 14:03
  • I am using Kubuntu so KWin window manager. I have removed the border as well as hidden the title bar. KWin has no control on the menubar set by Mathematica. The menubar also does not respect the gtk or qt themes(i tried to force it). – Bimaphys Aug 31 '21 at 14:17
  • 2
    The Linux FrontEnd looks for a custom Qt stylesheet in ~/.Mathematica/FrontEnd/frontend.css. You "should" be able to customize it using that. That is about all I can say about it though, I've never written one of these before. – ihojnicki Aug 31 '21 at 19:54
  • 1
    DarkMode may be of interest. – LouisB Aug 31 '21 at 19:54
  • @ihojnicki Wow, that's so helpful, thank you very much for that pointer. I had no idea. – Carl Lange Sep 01 '21 at 15:29

1 Answers1

5

Thanks to @ihojnicki, this is in fact possible.

Since the frontend looks in ~/.Mathematica/FrontEnd/frontend.css for custom Qt CSS, we can write our own to change the colours of the various elements.

Creating that file and adding the contents

QScrollBar:vertical {
  background: green;
  width: 20px;
}
QScrollBar::handle:vertical {
  background: red;
  min-height: 0px;
}
QMenu {
  background-color: #ababab; /* sets background of the menu */
  border: 1px solid black;
}

QMenu::item { /* sets background of menu item. set this to something non-transparent if you want menu color and menu item color to be different */ background-color: transparent; }

QMenu::item:selected { /* when user selects item using mouse or keyboard */ background-color: #654321; }

QMenuBar { background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 lightgray, stop: 1 red ); spacing: 3px; /* spacing between menu bar items */ }

QMenuBar::item { padding: 1px 4px; background: transparent; border-radius: 4px; }

QMenuBar::item:selected { /* when selected using mouse or keyboard */ background: #a8a8a8; }

QMenuBar::item:pressed { background: #888888; }

we can get this frankly beautiful colour arrangement:

enter image description here

Reading some of the Qt documentation should get you much of the way to a matching Frontend.

Carl Lange
  • 13,065
  • 1
  • 36
  • 70
  • Thank you so much for the help. I created the file but nothing happened in my case. Is there some other step that I need to follow to tell mathematica to use the css file. I tried your code as well as a few other to realise that mathematica is not looking for the file ~/.Mathematica/FrontEnd/frontend.css – Bimaphys Sep 02 '21 at 05:25
  • Oh yeah? What does $UserBaseDirectory evaluate to? – Carl Lange Sep 02 '21 at 08:00
  • I checked it. It outputs ~/.Mathematica. – Bimaphys Sep 02 '21 at 10:27
  • Strange - unfortunately I have no idea why it wouldn't pick it up, since it works perfectly for me. Perhaps @ihojnicki has some extra info. – Carl Lange Sep 02 '21 at 11:40
  • @Bimaphys, which version are you using? 12.0? Look like this requires 12.1 or later. – ihojnicki Sep 02 '21 at 12:53
  • @ihojnicki Oh..okay. I am using 12.0. I will try this once I update to the newest version. Thanks for the help. – Bimaphys Sep 02 '21 at 13:17
  • @CarlLange Thank you. Really appreciate the help. – Bimaphys Sep 02 '21 at 13:18
  • @Bimaphys If your question is answered, consider marking the answer as accepted! – Carl Lange Sep 02 '21 at 14:06