all repos — fluxbox @ c52a84a1704a2963b3d454a43617d8911778fb72

custom fork of the fluxbox windowmanager

make wallpapers do The Right Thing (tm)
Mark Tiefenbruck mark@fluxbox.org
commit

c52a84a1704a2963b3d454a43617d8911778fb72

parent

9e259590a2a59b89471bf3f42366c2209c69bf9c

5 files changed, 71 insertions(+), 69 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,5 +1,8 @@

(Format: Year/Month/Day) Changes for 1.1 +*08/08/06: + * Automatically restore the previous background on startup (Mark) + RootTheme.cc/hh util/fbsetbg startfluxbox.in *08/08/05: * Fixed Focus key command (Mark) CurrentWindowCmd.cc/hh FocusableList.cc/hh
M src/RootTheme.ccsrc/RootTheme.cc

@@ -150,7 +150,8 @@ RootTheme::RootTheme(FbTk::ImageControl &image_control):

FbTk::Theme(image_control.screenNumber()), m_background(new BackgroundItem(*this, "background", "Background")), m_opgc(RootWindow(FbTk::App::instance()->display(), image_control.screenNumber())), - m_image_ctrl(image_control) { + m_image_ctrl(image_control), + m_first(true) { Display *disp = FbTk::App::instance()->display(); m_opgc.setForeground(WhitePixel(disp, screenNum())^BlackPixel(disp, screenNum()));

@@ -183,10 +184,6 @@

if (!m_background->changed()) return; - // style doesn't wish to change the background - if (strstr(m_background->options().c_str(), "none") != 0) - return; - // // Else parse background from style //

@@ -197,37 +194,35 @@ // handle background option in style

std::string filename = m_background->filename(); FbTk::StringUtil::removeTrailingWhitespace(filename); FbTk::StringUtil::removeFirstWhitespace(filename); + // if background argument is a file then // parse image options and call image setting // command specified in the resources filename = FbTk::StringUtil::expandFilename(filename); - if (FbTk::FileUtil::isRegularFile(filename.c_str())) { + std::string cmd = realProgramName("fbsetbg") + (m_first ? " -z " : " -Z "); + + // style doesn't wish to change the background + if (strstr(m_background->options().c_str(), "none") != 0) { + if (!m_first) + return; + } else if (FbTk::FileUtil::isRegularFile(filename.c_str())) { // parse options - std::string options = "-F "; if (strstr(m_background->options().c_str(), "tiled") != 0) - options = "-T "; - if (strstr(m_background->options().c_str(), "centered") != 0) - options = "-C "; - if (strstr(m_background->options().c_str(), "aspect") != 0) - options = "-A "; - - // compose wallpaper application "fbsetbg" with argumetns - std::string commandargs = realProgramName("fbsetbg") + " " + options + - filename; - - // call command with options - FbCommands::ExecuteCmd exec(commandargs, screenNum()); - exec.execute(); + cmd += "-t "; + else if (strstr(m_background->options().c_str(), "centered") != 0) + cmd += "-c "; + else if (strstr(m_background->options().c_str(), "aspect") != 0) + cmd += "-a "; + else + cmd += "-f "; + cmd += filename; } else if (FbTk::FileUtil::isDirectory(filename.c_str()) && - strstr(m_background->options().c_str(), "random") != 0) { - std::string commandargs = realProgramName("fbsetbg") + " -R " + - filename; - FbCommands::ExecuteCmd exec(commandargs, screenNum()); - exec.execute(); + strstr(m_background->options().c_str(), "random") != 0) { + cmd += "-r " + filename; } else { // render normal texture with fbsetroot - + cmd += "-b "; // Make sure the color strings are valid, // so we dont pass any `commands` that can be executed

@@ -240,23 +235,26 @@ screenNum());

std::string options; if (color_valid) - options += "-foreground '" + m_background->colorString() + "' "; + cmd += "-foreground '" + m_background->colorString() + "' "; if (color_to_valid) - options += "-background '" + m_background->colorToString() + "' "; + cmd += "-background '" + m_background->colorToString() + "' "; if (strstr(m_background->options().c_str(), "mod") != 0) - options += "-mod " + m_background->modX() + " " + m_background->modY(); + cmd += "-mod " + m_background->modX() + " " + m_background->modY(); else if ((*m_background)->type() & FbTk::Texture::SOLID && color_valid) - options += "-solid '" + m_background->colorString() + "' "; - + cmd += "-solid '" + m_background->colorString() + "' "; else if ((*m_background)->type() & FbTk::Texture::GRADIENT) { - options += "-gradient '" + m_background->options() + "'"; + // remove whitespace from the options, since fbsetroot doesn't care + // and dealing with sh and fbsetbg is impossible if we don't + std::string options = m_background->options(); + options = FbTk::StringUtil::replaceString(options, " ", ""); + options = FbTk::StringUtil::replaceString(options, "\t", ""); + cmd += "-gradient " + options; } - - std::string commandargs = realProgramName("fbsetroot") + " " + options; - - FbCommands::ExecuteCmd exec(commandargs, screenNum()); - exec.execute(); } + // call command with options + FbCommands::ExecuteCmd exec(cmd, screenNum()); + m_first = false; + exec.execute(); }
M src/RootTheme.hhsrc/RootTheme.hh

@@ -64,7 +64,7 @@ private:

BackgroundItem *m_background;///< background image/texture FbTk::GContext m_opgc; FbTk::ImageControl &m_image_ctrl; ///< image control for rendering background texture - + bool m_first; }; #endif // ROOTTHEME_HH
M util/fbsetbgutil/fbsetbg

@@ -155,14 +155,14 @@ remembercommand() {

grep -vs "|${DISPLAY}$" ${lastwallpaper} > ${lastwallpaper}.tmp mv -f ${lastwallpaper}.tmp ${lastwallpaper} if [ "$option" = fbsetroot ]; then - echo $option"|$wallpaper|"$DISPLAY >> $lastwallpaper + echo $option"|$wallpaper|$style|"$DISPLAY >> $lastwallpaper return fi # Make dir/../../path/file.jpg work case $wallpaper in # no spaces allowed between the varname and '|' - /*) echo $option $option2"|$wallpaper|"$DISPLAY >> $lastwallpaper ;; - *) echo $option $option2"|$PWD/$wallpaper|"$DISPLAY >> $lastwallpaper ;; + /*) echo $option $option2"|$wallpaper|$style|"$DISPLAY >> $lastwallpaper ;; + *) echo $option $option2"|$PWD/$wallpaper|$style|"$DISPLAY >> $lastwallpaper ;; esac }

@@ -252,13 +252,11 @@ shift ;;

-b) option=fbsetroot shift wallpaper=$* - use_fbsetroot break ;; -B) option=fbsetroot shift wallpaper=$* remember=false - use_fbsetroot break ;; -r) option2=$option option=random

@@ -285,15 +283,36 @@ if [ -z "$wallpaper" ]; then

message "No previous wallpaper recorded for display ${DISPLAY}" exit 1 fi - if [ "$option" = "fbsetroot" ]; then - use_fbsetroot - fi else message "No previous wallpaper recorded for display ${DISPLAY}" exit 1 fi remember=false break ;; + -z) + if [ -r "$lastwallpaper" ]; then + option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1` + option2=`echo $option|cut -d' ' -f2` + option=`echo $option|cut -d' ' -f1` + style=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f3` + wallpaper=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f2` + if [ -z "$wallpaper" ]; then + option=`grep "|${DISPLAY}.0$" $lastwallpaper|cut -d'|' -f1` + option2=`echo $option|cut -d' ' -f2` + option=`echo $option|cut -d' ' -f1` + style=`grep "|${DISPLAY}.0$" $lastwallpaper|cut -d'|' -f3` + wallpaper=`grep "|${DISPLAY}.0$" $lastwallpaper|cut -d'|' -f2` + fi + fi + if [ "$style" != "style" -a -n "$wallpaper" ]; then + remember=false + break + fi + style="style" + shift ;; + -Z) + style="style" + shift ;; -p) display_tips ; exit 0 ;; -h) display_help ; exit 0 ;; --)

@@ -322,6 +341,10 @@ break

fi ;; esac done + +if [ "$option" = "fbsetroot" ]; then + use_fbsetroot +fi # Find the default wallpapersetter if [ "$setterfromcommandline" != true ]; then
M util/startfluxbox.inutil/startfluxbox.in

@@ -39,30 +39,8 @@ # fluxbox startup-script:

# # Lines starting with a '#' are ignored. -# This sets a black background - -@pkgprefix@fbsetroot@pkgsuffix@ -solid black - -# You can set your favourite wallpaper here. You will also need to uncomment the -# line in $HOME/.@pkgprefix@fluxbox@pkgsuffix@/overlay or else your style will override it. -# -# @pkgprefix@fbsetbg@pkgsuffix@ -f $HOME/.@pkgprefix@fluxbox@pkgsuffix@/backgrounds/wallpaper.png - -# Other examples. Check man xset for details. -# -# Turn off beeps: -# xset -b -# -# Increase the keyboard repeat-rate: -# xset r rate 195 35 -# -# Your own fonts-dir: -# xset +fp "$HOME/.fonts" -# # Change your keymap: -# xmodmap "$HOME/.Xmodmap" - - +xmodmap "$HOME/.Xmodmap" # Applications you want to run with fluxbox. # MAKE SURE THAT APPS THAT KEEP RUNNING HAVE AN ''&'' AT THE END.