Issue with the Separate entry in Appearance>Wallpaper  [Solved]

Help for MX Fluxbox
When asking for help, use Quick System Info from MX Tools. It will be properly formatted using the following steps.
1. Click on Quick System Info in MX Tools
2. Right click in your post and paste.
Message
Author
User avatar
siamhie
Global Moderator
Posts: 3785
Joined: Fri Aug 20, 2021 5:45 pm

Re: Issue with the Separate entry in Appearance>Wallpaper

#11 Post by siamhie »

@Melber I just tested it again (with my modified mxfb-seperate-backgrounds script) 5 times and it works just fine.

When you disable the separate wallpaper, you have to make sure to log out and then back in for your original image selected in Nitrogen to show.


The only thing I see building up is in the keys file (at the bottom). The user may want to go in and remove all of the hashtag entries (at the bottom) so that the keys file doesn't get too big.

Code: Select all

# center and resize 70%
Mod1 KP_5 :MacroCmd {ResizeTo 70% 70% } {MoveTo 00 00 Center}
# toggle full screen / restore
Mod1 KP_0 :ToggleCmd {Maximize} {Restore}
#---------------------------------------------------------------

#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
This is my Fluxbox . There are many others like it, but this one is mine. My Fluxbox is my best friend. It is my life.
I must master it as I must master my life. Without me, my Fluxbox is useless. Without my Fluxbox, I am useless.

User avatar
Melber
Developer
Posts: 1443
Joined: Tue Mar 23, 2021 4:19 pm

Re: Issue with the Separate entry in Appearance>Wallpaper

#12 Post by Melber »

siamhie wrote: Fri Dec 01, 2023 11:15 am @Melber I just tested it again (with my modified mxfb-seperate-backgrounds script) 5 times and it works just fine.
Also if you do the following?

select separate backgrounds > select separate backgrounds again > disable separate backgrounds
or
disable separate backgrounds > select separate backgrounds

I think they would leave both nitrogen and feh commented out in the startup file (can't check myself atm)

User avatar
siamhie
Global Moderator
Posts: 3785
Joined: Fri Aug 20, 2021 5:45 pm

Re: Issue with the Separate entry in Appearance>Wallpaper

#13 Post by siamhie »

@Melber Seems that if you select separate background, then select separate background again, it will double up the hashtag for the nitrogen command.

Code: Select all

#get last background selected
#~/.fehbg
##nitrogen --restore

Now you have to select disable two times in a row for both hashtags to be removed.

Code: Select all

#get last background selected
###~/.fehbg
nitrogen --restore

So I think users who initially setup separate backgrounds should disable that choice before setting up new backgrounds or else they will need to select disable until all the hashtags are removed (or edit the startup file manually).
This is my Fluxbox . There are many others like it, but this one is mine. My Fluxbox is my best friend. It is my life.
I must master it as I must master my life. Without me, my Fluxbox is useless. Without my Fluxbox, I am useless.

User avatar
Melber
Developer
Posts: 1443
Joined: Tue Mar 23, 2021 4:19 pm

Re: Issue with the Separate entry in Appearance>Wallpaper

#14 Post by Melber »

or we use the code I suggested, which should stop multiple comment hashes being added to the startup file even if the user selects things in the wrong order...

User avatar
siamhie
Global Moderator
Posts: 3785
Joined: Fri Aug 20, 2021 5:45 pm

Re: Issue with the Separate entry in Appearance>Wallpaper

#15 Post by siamhie »

Melber wrote: Fri Dec 01, 2023 12:11 pm or we use the code I suggested, which should stop multiple comment hashes being added to the startup file even if the user selects things in the wrong order...
@Melber For some strange reason the original script is working for me. When I disable Separate, nitrogen gets uncommented in startup. (you will still need to log out and back in for it to take affect)


Now I will try your fix and report back.
This is my Fluxbox . There are many others like it, but this one is mine. My Fluxbox is my best friend. It is my life.
I must master it as I must master my life. Without me, my Fluxbox is useless. Without my Fluxbox, I am useless.

User avatar
siamhie
Global Moderator
Posts: 3785
Joined: Fri Aug 20, 2021 5:45 pm

Re: Issue with the Separate entry in Appearance>Wallpaper  [Solved]

#16 Post by siamhie »

@Melber @Jerry3904 We have a winner. :number1:

Edited the script using Melber's suggested code and I no longer get multiple hashtags for the nitrogen command, plus there is no need to log out and back in for disable to take affect.
Also after you've setup your desktops, you don't need to cycle through the desktops to get the first one to recognize the change. This seems to have killed three birds with one stone. :dancingman:


Here is the working mxfb-separate-backgrounds script. I will close this thread as solved. Many thanks again to Melber.

Code: Select all

#!/bin/bash

# Script to configure separate backgrounds for each Fluxbox Workspace
# Written by user PPC and modified by MX Devs 
# Released under GPLv3

TEXTDOMAINDIR=/usr/share/locale 
export TEXTDOMAIN="mxfb-accessories"

#Confirmation Window
NOTIFICATION=$" Rotate Backgrounds has been disabled to avoid conflict."
MESSAGE1=$"  This app allows you to configure separate backgrounds for each Workspace  </b>"
HINT1=$" Selection windows will pop up  each Workspace."
HINT2=$" Type \"mxfb\" to jump to the MXFB backgrounds."
HINT3=$" Select the background you want and click OK."
NOTE1=$" NOTE 1: Background changes using the menu won't be permanent."
NOTE2=$" NOTE 2: Re-run this script when you add new workspaces!"
#NOTE3=$" NOTE 3: Disable nitrogen in startup file if using that app for image setting"
TITLE=$"MXFB -- separate workspace wallpapers"
BUTTON1=$"Cancel"
BUTTON2=$"Disable separate backgrounds"
BUTTON3=$"Setup separate backgrounds"
MESSAGE2=$"Separate backgrounds have been disabled."
TITLE2=$"Wallpaper selector"
TITLE3=$"Warning"
WARNING=$"There is no wallpaper image selected for Workspace $n... Will substitute 'mx_blue.jpg' to avoid any errors."


ICON=/usr/share/icons/mxflux.png

yad --center --window-icon=$ICON  --fix-window --text="
<b>$MESSAGE1\n

<b>--$HINT1
--$HINT2 
-- $HINT3 \n

$NOTE1
$NOTE2</b>
" \
--title=$"$TITLE" --window-icon=$ICON --text-align=center \
--button="<b>$BUTTON1</b>":1 \
--button="<b>$BUTTON2</b>":3 \
--button="<b>$BUTTON3</b>":2 \ 

foo=$?

[[ $foo -eq 1 ]] && exit 0

if [[ $foo -eq 3 ]]; then
#sed -i 's/ChangeWorkspace/#ChangeWorkspace/' ~/.fluxbox/keys 
awk '!/ChangeWorkspace/'  ~/.fluxbox/keys > temp && mv temp  ~/.fluxbox/keys
# block feh and enable nitrogen
HASHCHECK_NITROGEN=$(grep '#nitrogen' $HOME/.fluxbox/startup)
if [ ! -z "$HASHCHECK_NITROGEN" ]; then
    sed -i 's/#nitrogen/nitrogen/'  $HOME/.fluxbox/startup
fi

HASHCHECK_FEH=$(grep '#~/.fehbg' $HOME/.fluxbox/startup)
if [ -z "$HASHCHECK_FEH" ]; then
    sed -i 's/~\/.fehbg/#~\/.fehbg/'  $HOME/.fluxbox/startup
fi

nitrogen --restore
sed -i '/$full/d' $HOME/.fluxbox/lastwallpaper
yad  --title=$"$TITLE" --window-icon=$ICON  --center --message --text="$MESSAGE2" --fixed --no-buttons --timeout=5 
fluxbox-remote restart 

exit 0

fi

# block nitrogen and enable fehbg
HASHCHECK_NITROGEN=$(grep '#nitrogen' $HOME/.fluxbox/startup)
if [ -z "$HASHCHECK_NITROGEN" ]; then
    sed -i 's/nitrogen/#nitrogen/'  $HOME/.fluxbox/startup
fi

HASHCHECK_FEH=$(grep '#~/.fehbg' $HOME/.fluxbox/startup)
if [ ! -z "$HASHCHECK_FEH" ]; then
    sed -i 's/#~\/.fehbg/~\/.fehbg/'  $HOME/.fluxbox/startup
fi


#Check if the keys file has already been edited to allow costume wallpapers for each workspace:
##check if the keys file has a ChangeWorkspace entry
expression_to_find="ChangeWorkspace"
x=$(grep $expression_to_find ~/.fluxbox/keys)

if [ -z "$x" ]
then
      echo "\$x is empty- the keys file has not been edited, editing it to allow different wallpaper for each workspace"

	  #Backup the keys config file:
      cp ~/.fluxbox/keys ~/.restore/fluxbox/keys_BAK

      #Append the needed changes to the keys config file (the "\" is needed not to replace the variables:
      echo "#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
ChangeWorkspace :Exec fbsetbg ~/.fluxbox/backgrounds/numbered/\$(xprop -root _NET_CURRENT_DESKTOP |awk '{print \$3+1}').jpg" >> ~/.fluxbox/keys 

      else
        echo "\$x is NOT empty- the keys file seems to already allow custom wallpapers for each workspace."
     ###     echo Do you want to set up a single wallpaper for all Workspaces?
     ## If no, edit the keys file, removing the line that sets the ChangeWorkspace...
      
fi

#Create the needed folder
mkdir -p  ~/.fluxbox/backgrounds/numbered/

#Check how many Workspaces Fluxbox currently has:
number_of_workspaces=$(xdotool get_num_desktops)

#Remove existing numbered wallpapers to avoid failure when wallpaper is symlinked to /usr/share/backgrounds
rm ~/.fluxbox/backgrounds/numbered/*.jpg

#Disable Rotate backgrounds if running
STRING="Background.Delay: 0"

if ! grep -q "$STRING" $HOME/.ideskrc;
then
        sed -i 's/^\([[:blank:]]*Background\.Delay:\).*/\1 0/' "$HOME/.ideskrc"
yad --timeout=3 --no-buttons --geometry 500x100 --text-align=center --text="
<b>$NOTIFICATION</b>
"
fi

#Loop for as many workspaces as there is, selecting one wallpaper for each workspace
for ((n=1;n<=$number_of_workspaces;n++))
do
 cd /usr/share/backgrounds/
# select wallpaper:
 wallpaper=$(yad --title="$TITLE2" --center --window-icon=$ICON --file-selection --text="
 WORKSPACE $n
 " --text-align=center)
 # copy and rename wallpaper to match the current Workspace number:
 cp $wallpaper  ~/.fluxbox/backgrounds/numbered/$n.jpg
 
 if [ ! "$?" = "0" ]; then
    echo User canceled the script
    exit 0
fi
 
  #Check if wallpaper for current Workspace exists, if not, use a default one (mx_blue.jpg), to avoid errors. NOTE: if the users does not select any wallpaper at this time but a wallpaper for that workspace already existed, that previous selection will be maintained
  FILE=$n.jpg
 cd ~/.fluxbox/backgrounds/numbered/
 if [ ! -f "$FILE" ]
   then
    echo "File $FILE does not exist, using a default one- mx_blue.jpg"
    yad --center --window-icon=$ICON--title="$TITLE3" --text="$WARNING"
    cp  /usr/share/backgrounds/mx_blue.jpg ~/.fluxbox/backgrounds/numbered/$n.jpg
 fi

done
 echo Finished setting up workspace wallpapers, restarting fluxbox

#Implement the changes: 
fluxbox-remote restart
pgrep -u $(id -u)  -x idesk >/dev/null &&  idesktoggle idesk refresh
killall -SIGUSR1 conky 2>/dev/null

echo fluxbox restarted, script finished

This is my Fluxbox . There are many others like it, but this one is mine. My Fluxbox is my best friend. It is my life.
I must master it as I must master my life. Without me, my Fluxbox is useless. Without my Fluxbox, I am useless.

User avatar
Jerry3904
Administrator
Posts: 23529
Joined: Wed Jul 19, 2006 6:13 am

Re: Issue with the Separate entry in Appearance>Wallpaper

#17 Post by Jerry3904 »

Gee, I wasn't even needed. Nice work, people!

I'll update the package this weekend.
Production: MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
siamhie
Global Moderator
Posts: 3785
Joined: Fri Aug 20, 2021 5:45 pm

Re: Issue with the Separate entry in Appearance>Wallpaper

#18 Post by siamhie »

@Melber Forgot to mention that you can make as many changes in a row with the new script.
This is my Fluxbox . There are many others like it, but this one is mine. My Fluxbox is my best friend. It is my life.
I must master it as I must master my life. Without me, my Fluxbox is useless. Without my Fluxbox, I am useless.

User avatar
siamhie
Global Moderator
Posts: 3785
Joined: Fri Aug 20, 2021 5:45 pm

Re: Issue with the Separate entry in Appearance>Wallpaper

#19 Post by siamhie »

Jerry3904 wrote: Fri Dec 01, 2023 1:05 pm Gee, I wasn't even needed. Nice work, people!

I'll update the package this weekend.

@Jerry3904 There is one minor issue I just noticed. Every time you disable the separate desktop, a new line gets written to the keys file at the bottom.

Code: Select all

#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
#This executes fbsetbg every time workspace is changed to load <workspace number>.jpg from ~/.fluxbox/backgrounds/numbered/ 
This is my Fluxbox . There are many others like it, but this one is mine. My Fluxbox is my best friend. It is my life.
I must master it as I must master my life. Without me, my Fluxbox is useless. Without my Fluxbox, I am useless.

User avatar
Melber
Developer
Posts: 1443
Joined: Tue Mar 23, 2021 4:19 pm

Re: Issue with the Separate entry in Appearance>Wallpaper

#20 Post by Melber »

Jerry3904 wrote: Fri Dec 01, 2023 1:05 pm Gee, I wasn't even needed. Nice work, people!

I'll update the package this weekend.
We should also look at the translations.
Some strings are not being shown in German. Haven't checked other languages yet.

Post Reply

Return to “MX Fluxbox Official Release”